Partager via


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

  • Anonymous
    October 25, 2007
    PingBack from http://www.soundpages.net/computers/?p=4977

  • Anonymous
    June 11, 2008
    The comment has been removed

  • Anonymous
    September 10, 2008
    Adam -You rock - thanks for posting this!

  • Anonymous
    April 22, 2009
    This is great.  I scheduled to run get-antispamupdates every 10mins. =)