Ever need to schedule a script that you wrote with Exchange Management Shell to run on an interval?  This can be done through a scheduled task PowerShell script  The configuration is also a little bit tricky, because without the correct Powershell and Exchange Management settings in place this will not work.  The scheduled task will say it ran, but in the end will not have executed.

Setup your Scheduled Task PowerShell Script

Setup your scheduled task and make sure the following aspects are configured as shown below.

  • Open Task Scheduler
  • On the General tab, ensure that the account you are using has the proper permissions to Exchange and make sure “Run whether user is logged on or not” is selected.

scheduledtask1

  • On the Actions Tab, your powershell script will need to be configured to run as program by filling in the Program/Script and Add Arguments Fields.  See below for the syntax for each field and adjust accordingly for your environment.

scheduled task exchange

Program/Script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add Arguments (Optional): -command “. ‘C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1’; Connect-ExchangeServer -auto; . ‘C:\powershellscriptyouwrote.ps1’

Happy Scripting and Scheduling!

That is really all that is to it!  Scheduled task PowerShell scripts are a simple way to automate and successfully run the jobs you need every day.

error

Enjoy this blog? Please spread the word :)