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.

Copilot for Sales vs Copilot for Service – What's the Difference?

Copilot for Sales vs Copilot for Service – What's the Difference?

The Copilot products just keep coming! Microsoft Copilot for Service and Copilot for Sales became generally available through the New Commerce...

Important 2024 Microsoft Licensing Updates

Important 2024 Microsoft Licensing Updates

There is some big news in the world of Microsoft licensing this month! In the summer of 2023, Microsoft modified the licensing for Microsoft 365,...

Transforming TCRG's Legacy Systems into a Secure Cloud Future with CloudServus

Transforming TCRG's Legacy Systems into a Secure Cloud Future with CloudServus

TCRG (The Consolidated Rehab Group), specializing in vocational rehabilitation for military personnel and veterans, partnered CloudServus, a leader...