With the release of Exchange Server 2007, some administrators view the Exchange Management Shell (EMS) as a necessary evil. Microsoft omitted several functions from the Exchange Management Console, forcing administrators to perform them from the command line. Performing tasks manually may seem easier; but it can be time consuming if you're dealing with complex or repetitive functions. This tip explains how to use custom cmdlets to automate complex or repetitive functions in Exchange Server 2007.
Memorizing a series of commands may seem strange to Exchange administrators who are accustomed to simply pointing and clicking through Microsoft's GUI. The fact that you can't use the Exchange Management Shell for most common administrative tasks complicates matters further. But there are a few ways in which the EMS can make an Exchange Server 2007 administrator's life easier.
The Exchange Management Shell can automate complicated tasks via the command line using a cmdlet. While it might seem easier to perform the task manually, that may not be the case if it's something you must do on a regular basis. Automating the task may seem time consuming up front, but it saves you time in the long run.
A cmdlet is basically an easy-to-build text file that contains a series of commands. Typically, this text file will use the .PS1 extension, which designates it as a PowerShell cmdlet.
What kind of text does the file contain? Cmdlets can be as simple or as complex as you want. In their simplest form, cmdlets are nothing more than a series of either Windows PowerShell commands or Exchange-specific commands (assuming you're going to run the cmdlet through the Exchange Management Shell). For example, suppose that one of your responsibilities was to generate a monthly report of any Exchange 2007 user who's either a supervisor or a manager. You could do so using the following Exchange Management Shell commands:
Get-User –Filter {(Tit...
To continue reading for free, register below or login
To read more you must become a member of SearchExchange.com
');
// -->

le –EQ 'Supervisor') –or (Title –EQ 'Manager')} | Export-CSV "C:\report.csv"
This command structure is fairly simple; it obtains a list of users and then filters the list by users who have a title of either Supervisor or Manager. The results are then exported to a .CSV file.
Although this command's function is fairly simple, it involves quite a bit of typing. Furthermore, the command is a bit tedious, so it's easy to make a typing error. If I had to create this type of report each month, I would write a script that saves me from having to type or remember these commands each time.
With a good working knowledge of the Microsoft .NET framework, you can write more complex cmdlets that access classes and objects not exposed through any built-in commands.
About the author: Brien M. Posey, MCSE, is a five-time recipient of Microsoft's Most Valuable Professional award for his work with Exchange Server, Windows Server, Internet Information Services (IIS), and File Systems and Storage. Brien has served as CIO for a nationwide chain of hospitals and was once responsible for the Department of Information Management at Fort Knox. As a freelance technical writer, Brien has written for Microsoft, TechTarget, CNET, ZDNet, MSD2D, Relevant Technologies and other technology companies. You can visit Brien's personal website at www.brienposey.com.
Do you have comments on this tip? Let us know.
Please let others know how useful this tip was via the rating scale below. Do you know a helpful Exchange Server, Microsoft Outlook or SharePoint tip, timesaver or workaround? Email the editors to talk about writing for SearchExchange.com.