Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

One-liner from Scheduled task

$
0
0

Hi,

 

I' d like to run the following command in a scheduled task, 

 

Program: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

Argument: -command "& Send-MailMessage -To recipient@server.com -From monitoring@server.com -SmtpServer mail.server.com -Subject "Service status on $env:ComputerName" -body "$((gsv -Name Print*) | out-string)" -Encoding ([System.Text.Encoding]::UTF8)"

 

The script works inside a shell but it doesn't work in a scheduled task, so how should I change it to run in the scheduled task?

 

Cheers


Viewing all articles
Browse latest Browse all 21975

Trending Articles