Running Exchange 2010 scripts from Task Scheduler

By |2017-12-08T16:22:50+00:00November 4th, 2010|Exchange|0 Comments

Linked to my previous post around mailbox exports I had a need to run a mailbox export from a scheduled task (as it was going to take several days and my session would be reset if left idle for too long), so a scheduled task felt like a good solution, setup a scheduled task & manually start it. 

With the change to remote PowerShell with PowerShell 2 you have to do things a little differently than previously (where you could simply use import-module to load the exchange management ps commandlets), to do this for Exchange 2010 I did the following:


  • Create a scheduled task with no schedule and the following action:
    • Action: Start a program
    • Program / script: powershell.exe
    • Add arguments: -command ". ‘c:Program FilesMicrosoftExchange ServerV14binRemoteExchange.ps1’; Connect-ExchangeServer -auto; c:pathtoscriptscript.ps1"
  • On the general tab change the security options to look like this (the user account needs to have the required level of privilege granted by Exchange to do what ever it is your script has asked):
    • image
  • The ‘Run with highest privileges option’ was key for me, with that un-ticked the powershell process would start but nothing would actually happen, this is akin to pressing yes when prompted by the UAC dialog when you launch Exchange PowerShell.

You can then either setup a schedule if required or run the script on demand.


Leave A Comment

like what you see? 

Sign-up to our newsletter and never miss out on the latest blogs, events and tech news from the world of risual
Give it a try, you can unsubscribe anytime.