Powershell send-mailmessage - email to multiple recipients

前端 未结 7 2090
小蘑菇
小蘑菇 2020-11-29 07:10

I have this powershell script to sending emails with attachments, but when I add multiple recipients, only the first one gets the message. I\'ve read the documentation and s

7条回答
  •  半阙折子戏
    2020-11-29 07:42

    To define an array of strings it is more comfortable to use $var = @('User1 ', 'User2 ').

    $servername = hostname
    $smtpserver = 'localhost'
    $emailTo = @('username1 ', 'username2')
    $emailFrom = 'SomeServer '
    Send-MailMessage -To $emailTo -Subject 'Low available memory' -Body 'Warning' -SmtpServer $smtpserver -From $emailFrom
    

提交回复
热议问题