Powershell script unable to send to multiple recipients


I’m using a powershell script that will create an HTML report of disk space and send it as an email. Unfortunately I’m unable to get the script to send to more than one email recipient. The script I’m using can be found here:


Here are the relevant parts of the script…

I’m getting the following error


The MailMessage constructor you are using only takes one email address. See the MSDN documentation

You should try using Send-MailMessage instead because it’s -To parameter accepts an array of addresses

Send-MailMessage -from from@email.mail -To $recipients -Subject "Disk Space Report - $Date" -smptServer smtp.server -Attachments $freeSpaceFileName

Note: Send-MailMessage was introduced in PowerShell v2.0 so that’s why there are still examples that use other commands. If you need to use v1.0, then I will update my answer.


Powershell script unable to send to multiple recipients by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply