How to run Exchange .ps1 script as scheduled task
There are many reasons why one would like to run an Exchange powershell .ps1 script as a scheduled task.
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\Bin\ExShell.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'"
Enjoyed the post, what is next?
Grab our FULL RSS feed! or Email Updates then share it
-
Kojo
-
Kojo

