Create Exchange 2010 Individual Inbox Reports with PowerShell

Posted on April 26, 2013 by Jeff Hicks in Exchange Server with 0 Comments

In a previous article I demonstrated how to create Exchange 2010 Mailbox size reports with PowerShell. In that article we looked at usage data from the top level, such as a mailbox database. In this article, we’ll drill down a bit further into the mailbox itself and look at using the Get-MailboxFolderStatistics cmdlet to report on details of a single mailbox.

As before, I’m going to use the Exchange 2010 PowerShell Management console installed on my Windows 8 computer. Using the local management tools is really the best choice. As you might expect, Microsoft Exchange is a complex product when it comes to PowerShell, and using traditional PowerShell remoting is not as simple as you might think. Initializing the Exchange environment for a PowerShell session requires a lot of moving parts, which is why I find it easiest to install the management tools locally – I think you’ll have less opportunities for failure.

MailboxFolder Statistics

The cmdlet we’re going to be using is called Get-MailboxFolderStatistics. Let’s see how it works with my mailbox on my test Exchange 2010 server. By the way, the Exchange Information Store service must be running for these commands to succeed so if you try the commands and get no results, check the service.

You can use either the mailbox name or alias. You can also use Get-Mailbox and pipe it to Get-MailboxFolderStatistics. As you see below in Figure 1, the cmdlet generates a lot of information.

cmdlet Get-MailboxFolderStatistics

What you are actually seeing is information from a variety of folders in my mailbox. Let’s select a subset of properties to make this easier to visualize.

This is a bit easier to understand now, as you can see in Figure 2.

cmdlet Get-MailboxFolderStatistics

You can control the scope of statistics by using the –FolderScope parameter.

FolderScope values

The default value is All. The other values can come in handy for troubleshooting, but for reporting purposes I’m only concerned about the inbox. As you see below in Figure 3, I am now only looking within my inbox.

cmdlet mailbox Statistics

Sponsored

Data and Reports are subfolders within my Inbox. On one hand, Exchange has nicely formatted the values, but on the other, I like the raw values so I can do more with them. I can get the total size from the FolderandSubfolderSize property, but this too is a cooked value.

By the way, $inbox is an array of three elements, the first element being the Inbox. Looking at this property in Get-Member confirms my suspicions (based on the first article in this series on Exchange 2010 mailbox reports) that I can convert this value.

cmdlet mailbox Statistics

Let’s try.

Excellent! This means I can get a report in a more meaningful or useful value.

cmdlet mailbox Statistics

This works great for the inbox. But let’s step back a bit and get usage for the entire mailbox with a command like this:

Sponsored

All I’ve done is rerun the command, but this type gets all items (although I only need the first one, which has data on the top of the information store as you see in Figure 6).

cmdlet mailbox Statistics

The size value is in bytes. I could have used the FolderandSubFolderSize.toMB() method, but that rounds the value to 3. If I need something in MB but a bit more granular, I can get the value in bytes and then divide by 1MB. I’ll use the .NET [math] class to round the result to two decimal places.

cmdlet mailbox Statistics

To get a breakdown, say, between Inbox, Deleted Items, and Sent Items is a bit more complicated. Unfortunately, the –FolderScope parameter can only take a single value, so we have to get everything and filter for the items we want. Here’s a block of Powershell code that would work best in a script.

When executed against my mailbox I get a nice result as you can see below.

cmdlet mailbox Statistics

 

I hope this gives you some ideas on how to report on an individual mailbox. Naturally, I assume you are interested in applying these techniques to multiple mailboxes. In my next article I’ll demonstrate how to scale out with these ideas.

Sponsored

Tagged with ,