Managing Exchange Server 2010 : The Exchange Management Shell (part 3) - Reporting with the Exchange Management Shell

1/23/2011 12:03:04 PM

5. Reporting with the Exchange Management Shell

The Exchange Management Shell can actually be very effectively used for creating reports. The EMS has quite a lot of powerful cmdlets, and with the pipelining option it is possible to create all kinds of reporting. I'll give you a few examples, although please bear in mind that the outputs for many of these examples have been edited for readability.

The Get-ExchangeServer cmdlet will return a list of all Exchange 2010 servers in the organization:

[Edited for readability]

With the –Identity option it is possible to retrieve the information for only one Exchange server, and when the Get-ExchangeServer cmdlet is used in a pipeline with the format-list command, all the detailed information for the server in question is shown:

[Edited for readability]

If you want to retrieve mailbox information from your Exchange server, the Get-Mailbox and Get-MailboxStatistics cmdlets can be used:

[Edited for readability]

To get detailed information about a particular mailbox, the output of that Mailbox's identity can be piped to the Format-List command:

[Edited for readability]

The Get-MailboxStatistics cmdlet retrieves detailed information about Mailbox usage from an Exchange Server:

[Edited for readability]

So the Get-MailboxStatistics cmdlet gives lots of information about usage. To get some real reporting information, PowerShell has an option to convert its output to HTML. So, when you enter the following command...

... nothing is logged to the screen, but an HTML file is created in the directory where the PowerShell is running. Use Internet Explorer to open the output file:

Figure 4. Output of the Get-MailboxStatistics cmdlet redirected to an HTML file.

Using just the DisplayName is not really useful, so let's add some more parameters:

This will give the following HMTL file:

Figure 5. Detailed information about mailbox usage redirected to an HTML file.

Much nicer!


If you're enjoying pipelining, it's also possible to use the PowerShell Out-File option instead of redirecting using the ">".

Now let's create a small script with some variables:

  • $Now contains the date and time the script runs.

  • $BodyStyle contains a value used to retrieve a stylesheet to customize the HMTL file.

  • $MBXOutput contains the actual output from the Get-MailboxStatistics cmdlet.

Your script should look something like this:

Save this file as reporting.ps1 and run the script. It will still show the output of the query, but now it'll be beautifully formatted according the CSS style sheet. This methodology will allow you to create some really cool custom reporting setups.

Video tutorials
- How To Install Windows 8

- How To Install Windows Server 2012

- How To Install Windows Server 2012 On VirtualBox

- How To Disable Windows 8 Metro UI

- How To Install Windows Store Apps From Windows 8 Classic Desktop

- How To Disable Windows Update in Windows 8

- How To Disable Windows 8 Metro UI

- How To Add Widgets To Windows 8 Lock Screen

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010
programming4us programming4us