I have the following powershell commnad
Send-MailMessage -From <my email> -To <my email> -Subject "subject with some-word-with-hyphens" -SmtpServer <smtp server name> -Attachment <filename>
This command works interactively in powershell window. When I schedule it with Windows task scheduler the following things happen.
1. It gives error message saying positional parameter not found for the hyphenated word.
2. If the hyphenated word is removed then the email is not sent.
3. I cannot redirect errors to a log file by using 2>&1 and there is no way to capture error output.
Thanks for any help on this one.