I'm trying to send a mail using PowerShell with below command:
powershell -command "& {Send-MailMessage -To "xxxxx@xx.com" -From "xxxx@domain.com" -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 'xxx@xx.com'. At line:1 char:20 + & {Send-MailMessage <<<< -To "xxx@xx.com -From "xxx@xx.com -SMTPServer xxxx.xx.com -Subject "Daily report" -Body "service is running"} + CategoryInfo : InvalidArgument: (:) [Send-MailMessage], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SendMailMessage