I am trying to call a function with the following parameter signature:
Param ( [Parameter(Mandatory=$true)][string]$Subject, [Parameter(Mandatory=$true)][string]$JobResult, [Parameter(Mandatory=$true)]$Body, [Parameter(Mandatory=$true)][System.String[]] $Recipients )
I invoke it with:
[string[]] $ToAddresses = @("abc@xyz.com", "sa@xyz.com") Send-HtmlEmail -Subject "Save to Server" -JobResult "Results" -Body "New Body", -Recipients $ToAddresses
which returns the error
A positional parameter cannot be found that accepts argument 'System.String[]'.
If I change the Recipient argument to
Send-HtmlEmail -Subject "Save Outlook to Server" -JobResult "Results" -Body "New Body", -Recipients (,$ToAddresses)
the error is
A positional parameter cannot be found that accepts argument 'System.Object[]'How can I do this correctly?