Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions Links


SQL Server DBA Jobs

How to successfully separate email in Powershell

03 February,2020 by Tom Collins

Question: I'm trying to send an email with multiple recipients in Powershell, and getting an exception  error message:

Exception calling "Add" with "1" argument(s): "An invalid character was found in the mail header: ';'."

When I revert to send the email to one recipient - the email is successfull . What is the correct way to pass multiple recipients for powershell email.

Some more information that may assist in troubleshooting.

1) When I hardcode the email addresses in the Powershell code  e.g $emailTo = "[email protected],[email protected]"  it works ok . 

2)When I attempt to pass the values in as input parameters the errors are generated. 

param (

$emailTo = "$emailTo"

An example of how I'm executing the script:

.\SQL_Server_Audit.ps1  -emailTo "[email protected];[email protected]"   


Answer: Looking at the code examples you've posted, there are 2 separate issues. 

Issue 1 : the email separator. You've reported the message - Exception calling "Add" with "1" argument(s): "An invalid character was found in the mail header: ';'."

If you change the separator to "," it will work

issue 2 :   You're passing the multiple recipients   with doubles quotes  ""   , but this will throw an error. Change the double quotes to single quotes '' , and the issue will be fixed

In summary , when calling the powershell file it should be:

.\SQL_Server_Audit.ps1  -emailTo '[email protected],[email protected]'   


Read more on Powershell email 

SQL Server – Send email using Powershell (SQL Server DBA)

Send email from Powershell with attachment




Author: Tom Collins (


Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment on How to successfully separate email in Powershell | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer