Exchange 2007 Script: how to run as a scheduled task?

Because this information was so unbelievably hard to track down I thought I'd post this. This is so strange to me, I mean, isn't the idea of most scripting to run jobs unattended at specific times? Whew!

Basically, the process is you have to call powershell.exe, then load the Exchange extensions, then pass it the command that calls the script. You're supposed to be able to use -noexit so you can watch it run, and call exshell.psc1 directly via the run line -psconsolefile "C:\Program Files\Microsoft\Exchange Server\Bin\exshell.psc1", but I could not get it work using either of these. SO, we run the task starting in the Exchange bin directory as below.

Run: powershell -psconsolefile exshell.psc1 -command "& {c:\yourscript.ps1}"

Start in: "C:\Program Files\Microsoft\Exchange Server\Bin"

Run as: <account with rights to do whatever is in your script>

Comments (4)

  1. top man, I have been hunting for this with a view to creating a combined VB and Powershell script to automate the failover between Exchange 2007 servers using SCR.

    I have the solution tested and working perfectly with a manual failover and this is the one of the final requirements for completing this .

    Thank you very much!

    All the best


  2. David Zazzo says:

    Adam –

    You rock – thanks for posting this!

  3. Lloyd says:

    This is great.  I scheduled to run get-antispamupdates every 10mins. =)

Skip to main content