I'm trying to send a mail using PowerShell with below command:
powershell -command "& {Send-MailMessage -To "[email protected]" -From "[email protected]" -SMTPServer xxx.xx.com -Subject "report" -Body "service is running"}"
but I'm getting this error:
Send-MailMessage : A positional parameter cannot be found that accepts argument '[email protected]'. At line:1 char:20 + & {Send-MailMessage <<<< -To "[email protected] -From "[email protected] -SMTPServer xxxx.xx.com -Subject "Daily report" -Body "service is running"} + CategoryInfo : InvalidArgument: (:) [Send-MailMessage], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SendMailMessage