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.

The Benefits of Transitioning to Microsoft Fabric for Power BI Users

The Benefits of Transitioning to Microsoft Fabric for Power BI Users

As Microsoft rolls out its comprehensive analytics platform, Microsoft Fabric, existing Power BI users face a pivotal moment of transition. This...

Facing SQL Server 2014 End of Support: Upgrade or Migrate?

Facing SQL Server 2014 End of Support: Upgrade or Migrate?

July 9th, 2024 marked theend of support(EOS), for SQL Server 2014following that of Windows and SQL Server 2012 in the past few years. This end of...

Microsoft Q2 2024 Licensing Updates

Microsoft Q2 2024 Licensing Updates

Microsoft continues to deliver a stream of thrilling announcements throughout 2024!