Hi all,
I have a .ps1 script that runs some Exchange commands.When executing from Exchange management shell it works.
Command when run directly from Exchange management shell:
.\Get-ExchangeEnvironmentReport -HTMLReport C:\Scripts\ExchangeReport.html -SendMail:$true -MailFrom:postmaster@domain.com -MailTo:user1@domain.com -MailServer:mail.domain.com
But when i run from scheduled task it says success,but no email is sent.
Here its how ik look in Scheduled task:
Action: start a program
Program/script: powershell (also tried powershell.exe)
Add arguments: -c "pushd C:\scripts; C:\scripts\Get-ExchangeEnvironmentReport.ps1 -HTMLReport C:\Scripts\ExchangeReport.html -SendMail:$true -MailFrom:postmaster@domain.com -MailTo:user1@domain.com -MailServer:mail.domain.com"
I guess it failes because powershell doesnt understand Exchange commands,so i tried this:
-command ". 'C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; C:\Scripts\Get-ExchangeEnvironmentReport.ps1" -HTMLReport C:\Scripts\ExchangeReport.html -SendMail:$true -MailFrom:postmaster@domain.com -MailTo:user1@domain.com -MailServer:mail.domain.com"
This one also failed.Any idea how to get this working?
t