Skip to the main content.

1 min read

Generating HTML Web Reports through Exchange Management Shell

 

As you know Exchange Management Shell is an extension of Windows PowerShell (PS). Today I found a really useful PS command to generate HTML reports that include data generated through Exchange Management Shell commands. In an effort to create a “Dashboard” for our Exchange environment, I’ve been trying to find a way to gather information in Exchange Shell and publish that data into an HTML report. The ConvertTo-HTML command will do exactly that.

The PS command is called ConvertTo-HTML. For more details on the command itself, please refer to the MS Technet article. In this article I am going to jump right into some reports I’ve created for myself.

http://technet.microsoft.com/en-us/library/dd347572.aspx

 

Generate a Web Report for Number of Mailboxes Per Database on a Server:

Get-Mailbox -server <servername> | Group-Object -Property:Database | Select-Object Name,Count | sort Name | ConvertTo-HTML –title “Number of Mailboxes Per Database: EXCHSRVR1” -Property DisplayName, ItemCount –pre “Produced by Dave Rowe” –post “Contact Dave for Questions” > C:tempMailboxesPerDB.htm

The output of this command produces a list of all DBs on the specified Exchange server (ex: EXCHSRVR1) and the total number of mailboxes per database. Then it sorts the output by Name (of the database) and converts it to an HTML page.

 

As you can see the formatting of the output is not great. You have to use some complex scripting to clean it up. Here is a sample of one I did just to add some space in the first column.

Get-Mailbox -server <SERVERS> | Group-Object -Property:Database | Select-Object Name,Count | sort Name | ConvertTo-HTML –title “Number of Mailboxes Per Database: EXCHSRVR1” -Property Name, Count | foreach {if($_ -like “*<tr><td>*”){$_ -replace “<tr><td>”, “<tr><td width=400>”}else{$_}} > C:tempMailboxesPerDB.htm

This script uses a foreach loop to find all “<tr><td>” tags and replace them with “<tr><td width=300>”. It’s a lot of complex code for a simple change, but makes the report much easier to read.

E2K7: How to Change the Recipient Scope

When managing Exchange 2007, the recipient scope for Exchange Management Shell (EMS) and Exchange Management Console (EMC) defaults to the domain...

Read More

Exchange 2010 Dynamic Distribution Group not working

There is a bug in the creation process for Dynamic Distribution Groups (DDG) in Exchange 2010. When you use the Exchange Management Shell to create a...

Read More

Exchange 2010 Edge and Threat Management Gateway

http://www.cgoosen.com/2010/05/securing-exchange-2010-with-forefront-threat-management-gateway-tmg-2010-part-1-the-introduction/

Read More