Running Exchange PowerShell as Scheduled Task

By |2017-12-08T16:23:40+00:00December 1st, 2011|Exchange|0 Comments

If you want to run any of the Exchange PowerShell commands from a standard PowerShell environment then you simply need to add in the following line in order to run it as if it is an Exchange Management Console:

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010

For example, the script below will output the size of the Exchange Databases to a file and can be run as a scheduled task:


Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010

Get-MailboxDatabase –Status | fl name, databasesize | out-file C:dbsize.txt


What we can do then is save the above script to a .ps1 file and then edit the action to start PowerShell.exe and put the arguments as the script that you want to run:


This can be set up with the usual Scheduled Task settings and with the PowerShell snap-in for Exchange added in should be able to use the Exchange PowerShell commands.



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.