Home > How to generate HTML reports with the Exchange Management Shell (EMS)
Tutorial:
EMAIL THIS LICENSING & REPRINTS

How to generate HTML reports with the Exchange Management Shell (EMS)

11 Jun 2008 | SearchExchange.com

Exchange Server tips, tutorials and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google

The Exchange Management Shell (EMS) in Exchange Server 2007 can generate valuable administrative reports. However, this involves cumbersome commands and generates a report that isn't universally usable. In this tip, Brien Posey details how to extract mailbox data and export it into an HTML-formatted report using the EMS.

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).

More on Exchange Server reporting:
ADVSoft MailDetective: Monitoring, statistics and analysis for Exchange Server

Free log reporting tool for HTTP and Exchange Server

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.

Create reports using the Exchange Management Shell in Exchange Server 2007 Figure 1. Results of the Get-MailboxStatistics | Select DisplayName, ItemCount | Sort ItemCount command.

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.

an HTML report generated through the Exchange Management Shell Figure 2. The converted report is in HTML format.

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:

Invoke-Item C:\Temp\Items.htm

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.

Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
Microsoft Exchange Server Monitoring and Logging
Error message: 'ID no: 8004100e Exchange System Manager'
IMAP list command only returns a list of Exchange public folders
A network connection problem or an offline server prevented delivery of the message
Monitor and search Exchange mailboxes for music and video files
How much bandwidth is required to send email in Exchange 2003?
Monitoring Outlook Web Access usage via IIS log files
What event log tracks user access to Exchange Server?
How to determine when an Exchange Server mailbox was last accessed by the owner
How to set up Microsoft Operations Manager (MOM) for Exchange Server monitoring
How to analyze Exchange Server SMTP log files in Microsoft Excel

Microsoft Exchange Server Scripts and Programming
EMS add-on tool generates graphical Exchange Server 2007 reports
A primer on the Exchange Server 2007 Exchange Management Shell
Use the Exchange Management Shell Set command to block senders
How to test Exchange Management Shell commands
Grant or deny permissions to access a user's Exchange 2007 mailbox
Control query results with Exchange Management Shell's Format command
How to use Exchange Management Shell's Filter command
How to use the Exchange Management Shell command syntax
Fix OWA message size limit issue after Exchange 2007 SP1 upgrade
Automatically save Microsoft Outlook email attachments to disk

Microsoft Exchange Server 2007
Virtualizing Exchange Server 2007 with Microsoft's Hyper-V
Configure Microsoft SharePoint mobile access via Exchange Server 2007
Troubleshoot Outlook 2007 error 0X8004010F on Exchange Server 2007
How to export Global Address List data to Microsoft Office Access
Create a group policy to prevent .PST file storage in Exchange 2007
Synchronizing the Windows Mobile emulator with Exchange Server 2007
Considerations for virtualizing an Exchange Server environment
EMS add-on tool generates graphical Exchange Server 2007 reports
Third-party Exchange Server 2007 backup and restore tools
A primer on the Exchange Server 2007 Exchange Management Shell
Microsoft Exchange Server 2007 Research

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
application program interface  (SearchExchange.com)
event sink  (SearchExchange.com)
synchronous groupware  (SearchExchange.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2004 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts