BACKGROUND IMAGE: iSTOCK/GETTY IMAGES
Exchange Server 2007 administrators can use the Exchange Management Shell (EMS) to extract valuable data from the server. Although this can be useful, there are a couple of problems with using the Exchange Management Shell as a reporting tool.
First, the commands that you must use can be cumbersome and complicated to implement. Second, output typically is written to the screen in text-only format, which isn't helpful for anyone else.
The Exchange Management Shell can be used to create reports in various formats. Here's a way to create an HTML report detailing the number of items in each Exchange mailbox that's readable in Internet Explorer (IE).
The Exchange Management Shell can produce robust reports in file formats that aren't proprietary to Exchange Server. Unfortunately, administrators still must use complex commands to create these. Once you understand how to use these commands, you can build them into a script so you don't have to enter them manually the next time you need to generate a report.
There are several ways to create reports, including using the Get-Mailbox Statistics command. This command also works with the Get-Mailbox command or any other Get commands within the EMS. However, a basic technique that doesn't involve the use of complicated commands is:
Get-MailboxStatistics | Select DisplayName, ItemCount | Sort ItemCount
This command is actually three different commands in one. It basically acquires all Exchange mailbox statistics, filters everything except for display names and item counts, and then sorts remaining data according to item count. Results of this command are shown in Figure 1.
We have created a report containing information about how many items each user has in his mailbox. Unfortunately, this report can't be sent to anyone else. Therefore, we must convert this report into HTML format that can be viewed using Internet Explorer (IE).
To do so, begin with the same basic command, but append the ConvertTo-HTML command. We'll also specify the properties that we have already extracted from Exchange using the Get-MailboxStatistics command. Finally, we must use the redirect command (>) and specify a filename to which the report should be outputted. The full command syntax is:
Get-MailboxStatistics | Select DisplayName, ItemCount | Sort ItemCount | ConvertTo-HTML –Property DisplayName, ItemCount >C:\temp\items.htm
When you execute this command, it doesn't seem to do anything. However, it creates the file: C:\Temp\Items.htm.
When you open Windows Explorer and double-click on the file, it will open IE and display a report similar to that shown in Figure 2.
If you don't want to use Windows Explorer to open your report, you can open it from the Exchange Management Shell. To do so, enter:
Although this command launches IE and opens your report, you can't append this command to the end of the previous command. Fortunately, if you're building a script, you can include this as a separate command within the script.
About the author: Brien M. Posey, MCSE, has previously received Microsoft's MVP award for Microsoft Exchange, Windows Server and Internet Information Server (IIS). He 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.