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.

Navigating the Future with Windows 365: Your Complete Cloud-Based Workspace

Navigating the Future with Windows 365: Your Complete Cloud-Based Workspace

Cloud computing has transformed the business landscape, offering unparalleled flexibility and efficiency. A leader in this evolution is Microsoft...

Microsoft Fabric vs. Power BI: What's the Difference?

Microsoft Fabric vs. Power BI: What's the Difference?

It’s more important than ever today for businesses to make data-driven decisions. But while 90% of organizations indicate that data is increasingly...

Countdown to Windows Server 2012 R2 EOL: Upgrade & Migration Choices Explained

Countdown to Windows Server 2012 R2 EOL: Upgrade & Migration Choices Explained

The deadline for Windows Server 2012 support is fast approaching; the end of support date is October 10th, 2023. As this technology is set to become...