以下用于从PowerShell发送电子邮件的块
Function Mailer ($emailTo)
{
$message = @"
Some stuff that is meaningful
Thank you,
IT Department
Cotendo Corporation
it@cotendo.com
"@
$emailFrom = "noreply@<yourdomain>.com"
$subject="<Your Text Here>"
$smtpserver="<your mailhost>.<yourdomain>.com"
$smtp=new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject, $message)
}
以上代码可帮助我从PowerShell脚本发送电子邮件。我可以发送电子邮件到个人电子邮件,如abc@xyz.com,但如果有群组电子邮件或AD群组电子邮件收件人,那么我不能。
请帮我发送电子邮件给AD组或群组电子邮件ID,特殊权限要求或我也可以使用上面的脚本发送。
答案 0 :(得分:2)
Send-MailMessage [-To] <String[]> [-Subject] <String> [[-Body] <String> ] [[-SmtpServer] <String> ] -From <String> [-Attachments <String[]> ] [-Bcc <String[]> ] [-BodyAsHtml] [-Cc <String[]> ] [-Credential <PSCredential> ] [-DeliveryNotificationOption <DeliveryNotificationOptions> ] [-Encoding <Encoding> ] [-Port <Int32> ] [-Priority <MailPriority> ] [-UseSsl] [ <CommonParameters>]
您可以按照此链接向多个用户发送脚本