DISCLAIMER

lifeofanexchangeadministrator.blogspot.com is in no way affiliated with Microsoft Corp.
*Posts are sponsored by authors.
*All contents are posted by Authors in their own free will
*The steps mentioned in here may be performed at your free will and risk & it may vary from scenario to scenario

Friday, August 15, 2008

Scheduled Task Wizard to invoke Exchange Management Shell (EMS)

"Scheduled Task Wizard to invoke Exchange Management Shell (EMS)"

This can prove helpful when administrator wants to execute certain script or Task at a scheduled interval. For Example, Administrator may want to run 'get-mailboxstatistics' every midnight or at specific interval of time to know item-count of every mailbox or Administrator may want to Export GAL on weekly/monthly basis or any other task that Administrator wants to perform on regular basis and that too at a time when he is not in office.

I will be explaining this process with the screen-shots. So far, I have tested it in my lab & it works fine.


You may want to execute default scripts (%driveletter%\Program Files\Microsoft\Exchange Server\Scripts) or you can write your own script for a specific usage and save it as .ps1 file.

For Example, I am using below command and saved it in a File 'GalExport.ps1' :-
Get-Recipient select name, RecipientType, Alias, PrimarySmtpAddress, database export-csv c:\exports\galexport.csv

Usage of this script is to Export Users from GAL with some of their attributes in a CSV file.


STEP I: Create a New Scheduled Task















STEP II: Then Select Application Type; In Our Case it is going to be "Exchange Management Shell"












STEP III: Then Give a Name and Specify interval of this Task occurrence














STEP IV: Then Enter Time at which you want to invoke this task & check the Start date of this Task
STEP V: Then it will ask you for Admin User Account and its Password, please enter that


STEP VI: After that on the last page select "Open Advance Properties" option & click on Finish















STEP VII: Then in front of "Run" option type below syntax :-

C:\WINDOWS\system32\WINDOW~2\V1.0\powershell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -noexit command ". 'C:\Program Files\Microsoft\Exchange Server\Scripts\.ps1'"

Only the string highlighted in RED is going to be location and name of script that Administrator wants to run. In our Example it is, GalExport.ps1.

In General, This script can be a collection of Shell Commands or any other script which is compatible to execute with Exchange Shell.

Once we follow above mentioned procedure; it will invoke Exchange Management Shell at the mentioned interval and will perform its Task. In this case, key factor is Administrator need to know what task he/she wants to perform and should also know respective script/shell cmdlets for it.

Hope this was helpful :)
Thanks for your time while reading this article, and please feel free to convey your suggestions/questions.

Vikrant

1 comment:

Anonymous said...

Good one, was very helpful !!

- Vinit