Dressurausbildung Daniel Köck

Dresssurausbildung Koeck

Stern inaktivStern inaktivStern inaktivStern inaktivStern inaktiv
 

Seit Powershell 2.0 gibt es ein eigenes Cmdlet zum Versenden von E-Mails.

Das Cmdlet send-MailMessage enthält so ziemlich alle Parameter, die zum Versenden von Mails benötigt werden.

send-MailMessage [-To] <string[]> [-Subject] <string> -From <string> [[-Body] <string>] [[-SmtpServer] <string>] [-Attachments <string[]>] [-Bcc <string[]>] [-BodyAsHtml] [-Cc <string[]>] [-Credential <PSCredential>] [-DeliveryNotificationOption {None | OnSuccess | OnFailure | Delay | Never}] [-Encoding <Encoding>] [-Priority {Normal | Low | High}] [-UseSsl] <CommonParameters>]

Hier einige Beispiele aus der Powershell Hilfe:

Beispiel 1:
    
PS C:\> send-mailmessage -to "User01 <Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!>" -from "User02 <Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!>" -subject "Test mail"
    
This command sends an e-mail message from User01 to User02. The mail message has a subject, which is required, but it does not have a body, which is optional. Also, because the SmtpServer parameter is not specified, Send-MailMessage uses the value of the $PSEmailServer preference variable for the SMTP server.
    
Beispiel 2:

PS C:\> send-mailmessage -from "User01 <Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!>" -to "User02 <Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!>", 
"User03 <Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!>" -subject 
"Sending the Attachment" -body "Forgot to send the attachment. Sending now."
-Attachments "data.csv" -priority High -dno onSuccess, onFailure 
-smtpServer smtp.fabrikam.com
    

This command sends an e-mail message with an attachment from User01 to two other users. It specifies a priority value of "High" and requests a delivery notification by e-mail when the e-mail messages are delivered or when they fail.

Beispiel 3:

PS C:\> send-mailmessage -to "User01 <Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!>" -from "ITGroup <Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!>" 
-cc "User02 <Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!>" -bcc "ITMgr
<Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!>" -subject "Don't forget today's meeting!"
-credential domain01\admin01 -useSSL

    
    
This command sends an e-mail message from User01 to the ITGroup mailing list with a copy (CC) to User02 and a blind carbon copy (BCC) to the 
IT manager (ITMgr). The command uses the credentials of a domain administrator and the UseSSL parameter.

Copyright © winxperts4all.com. All Rights Reserved.