Scheduled Tasks and the Exchange Management Shell (EMS)

As an Exchange admin, one of my favorite features of a Windows OS is the trusty Task Scheduler. This simple capability allows me to generate reports, perform cleanup tasks, and ensure things in my environment stay configured as I expect. The one issue that I sometimes run into however is how to have the Task Scheduler run a task within the Exchange Management Shell (EMS;, so to make it easy I’m going to share that info with you.

As you can see in the screenshot below, we’ve got all of our fields populated.

The Action field is self-explanatory, but the data in the other three goes as follows:

Program/script:

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

Add arguments (optional):

-version 2.0 -NonInteractive -WindowStyle Hidden -command “. ‘C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1’; Connect-ExchangeServer -auto; .\ScriptName.ps1

Start in (optional):

D:\ABZ\Scheduled Tasks

-Eric

Leave a Reply

Your email address will not be published. Required fields are marked *