I have an Exchange 2010 ps1 script that i found online to check the status of my DAG and if there are any issues it emails me the details. I am trying to add this as a scheduled task but not having much success.

Create a scheduled task with the following for run program: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exeMake the following an argument -command ". 'D:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; D:\Scripts\SCRIPTNAME.ps1"

Make sure the path to RemoteExchage.ps1 is accurate for your environment. Also make sure the path to the script, in this example \Scripts.SCRIPTNAME.ps1, is the path to the script you're attempting to execute. The account that the task runs as will require access to powershell.exe, remoteexchange.ps1, the script you're attempting to run, and the required rights within Exchange to run the command.

Now the task completes but I don't get the email alert. If i run the ps1 manually it works and i get the alert, if i execute it via the scheduled task i don't get the alert(even though the task completes successfully.

Come to think of it, my explanation for your non-terminating job was wrong. It didn't terminate because the shell was waiting for the last double quote to be closed. Same effect, different cause. If my first explanation were correct, my scheduled jobs would never terminate either.

Anyhoo, if I were in your shoes, I'd do the following:* Launch powershell (not EMC) interactively as the same account that you're scheduling this task* Then run the three commands separately

If it fails on the first one, the error should give you a pretty clear hint. That'd fail for me for example because I have Exchange installed on the E drive.The second one failing would mean that you should be attending to bigger issues.The third shouldn't fail unless your test conditions differ from those of your schedule job.