Exchange create .ps1 script powershell scheduled task

There lots of reasons why someone would like to run an Exchange powershell .ps1 script as a scheduled task. For example scheduling a delta PST export during a migration.

In this post I will share with you how to achieve this on both Microsoft Exchange 2007 and Exchange 2010.   Obviously you should start by creating your .ps1 script for this article we will assume the script location is c:\pcs\YourScript.ps1

The idea is to run the powershell.exe add pass to it the Exchange powershell console as parameter and then finally specify the desired .ps1 script.

You should notice the difference in the path of the Exchange powershell console between Exchange 2007 and Exchange 2010.

Exchange 2007 exshell.psc1 is located at “”C:\Program Files\Microsoft\Exchange Server\Bin\exshell.psc1″”  

Exchange 2010 exshell.psc1 is located at “”C:\Program Files\Microsoft\Exchange Server\V14\Bin\exshell.psc1″”  

Notice the extra V14 in Exchange 2010 ?

So the full command to run would be

For Exchange 2007

PowerShell.exe -PSConsoleFile “C:\Program Files\Microsoft\Exchange Server\BinExShell.psc1” -Command “. ‘c:\pcs\YourScript.ps1′”

For Exchange 2010

PowerShell.exe -PSConsoleFile “C:\Program Files\Microsoft\Exchange Server\V14\Bin\ExShell.psc1” -Command “. ‘c:\pcs\YourScript.ps1′”

Many thanks to zero


Disclaimer : The author reserves the right not to be responsible for the topicality, correctness, completeness or quality of the information provided.

Leave a Reply

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

Time limit is exhausted. Please reload the CAPTCHA.