Reporting Mailbox Sizes on Microsoft Exchange 2010

The useful feature of displaying mailbox sizes is missing from Exchange Management Console (EMC) on MS Exchange 2010, so you cannot quickly estimate mailbox sizes on your Exchange Databases. You need to dive into powershell cmdlets to get this information. I agree that powershell cmdlets are powerful, there is no question about it. But gui is beautiful, Microsoft should have included a gui interface for this!

First of all, I am using Powershell version 2.0, since we host Exchange Services on Windows 2008 R2 platform. Before retrieving exchange information, let’s have a look on some useful utility powershell cmdlets that are extremely useful for pipelining multiple cmdlets.

  • Format-Table (alias ft): formats the output as a table
  • Get-Member (alias gm): get information about the objects that the cmdlets return (methods and properties)
  • Sort-Object (alias sort): Sort objects by property values
  • Select-Object (alias select): Selects objects or object properties
  • Import-CSV (alias ipcsv): Creates table-like custom objects from the items in a CSV file
  • Export-CSV (alias epcsv): Converts objects into a series of comma-separated (CSV) strings and saves the strings in a CSV file

We will use these cmdlets in our examples.

Get-MailboxStatistics is a basic building block to gather information about Exchange mailboxes. It returns several  information per mailbox, per database or per server. Run the following cmdlets using a different scope.

Get-MailboxStatistics -Identity <mailbox name>
Get-MailboxStatistics -Database <database name>
Get-MailboxStatistics -Server <server name>

Now run the following command to check out that mailbox objects that you can retrieve for each mailbox.

Get-MailboxStatistics -Identity <mailbox name> | Get-Member

or using the alias

Get-MailboxStatistics -Identity <mailbox name> | gm

MailboxStatistics objects

MailboxStatistics objects

There is tons of information that you can retrieve here, but usually you don’t need all these. Filter out the display items by using the Format-Table cmdlet

Get-MailboxStatistics -Identity <mailbox name> | Format-Table DisplayName, TotalItemSize

or again using the alias

Get-MailboxStatistics -Identity <mailbox name> | ft DisplayName, TotalItemSize

MailboxStatistics Filtering

MailboxStatistics Filtering

When you run Get-MailboxStatistics -database <database name> or a similar cmdlet, the information will not display clearly, you better sort the data by, let’s say, the mailbox size by running

Get-MailboxStatistics -database <database name> | sort TotalItemSize -Descending | ft DisplayName, TotalItemSize

or

Get-MailboxStatistics -database <database name> | sort TotalItemSize -Descending | select DisplayName, TotalItemSize –First 5

to display the top 5 mailboxes by TotalItemSize

or

Get-MailboxStatistics -database <database name> | sort TotalItemSize -Descending | select DisplayName, TotalItemSize | epcsv <path & export filename>

to export the data to a csv file.

Displaying mailbox sizes in bytes is not user friendly, so run the following cmdlet to display sizes in MB.

Get-MailboxStatistics -server <server name> | sort TotalItemSize -Descending | select DisplayName, StorageLimitStatus, @{label="Total Size (MB)";expression={$_.TotalItemSize.Value.ToMB()}}, @{label="Deleted Item Size (MB)";expression={$_.TotalDeletedItemSize.Value.ToMB()}}

Checkout the available methods of TotalItemSize by running the following

(Get-MailboxStatistics <mailbox name>).TotalItemSize.value | gm

TotalItemSize Methods

TotalItemSize Methods

If you need to make a mailbox size report for specific users, you can create a new file called c:\input.csv. Type in Mailbox on the first line and insert the specific mailbox names in every separate line. Save it and run the following command.

ipcsv "c:\input.csv" | ForEach-Object -Process {Get-Mailbox $_.Mailbox | select DisplayName,@{n="Size(MB)";e = {$MBXstat = Get-MailboxStatistics $_.name; $MBXstat.totalItemsize.value.toMB()}},@{n="DeletedSize(MB)";e = {$MBXstat = Get-MailboxStatistics $_.name; $MBXstat.totalDeletedItemsize.value.toMB()}},@{n="Items"; e = {$MBXstat = Get-MailboxStatistics $_.name ; $MBXstat.itemcount}},@{n="DeleteItems"; e = {$MBXstat = Get-MailboxStatistics $_.name ; $MBXstat.deleteditemcount}}} | epcsv "c:\output.csv"

(the example was taken from Memphis Technical Network site)

Finally, Get-MailboxFolderStatistics cmdlet breaks down the mailbox information per subfolder. Display the available objects by running

Get-MailboxFolderStatistics <mailbox name> | gm

MailboxFolderStatistics Objects

MailboxFolderStatistics Objects

Finally run

Get-MailboxFolderStatistics <mailbox name> | ft Identity, FolderSize, ItemsinFolder

to gather the folder sizes and the item count of a mailbox.

Hopefully these commands will give you a basic idea, how to use various cmdlets to format your mailbox size reports!

Advertisements

3 thoughts on “Reporting Mailbox Sizes on Microsoft Exchange 2010

  1. Problem is, Get-MailboxStatistics output just a display name – not unique and cant really be used as such. The other half of the information you need is in Get-Mailbox :- found answer in following link. once you have the data on all your mailboxes, and the output can be IMPORTED into excel you can do all your sorting etc and delete whatever you dont want

    ***if this is what you were looking for, please click this link and give the guy some credit.. i didnt come up with this, i just found it

    #REM http://www.experts-exchange.com/Software/Server_Software/Email_Servers/Exchange/Q_27828458.html

    $Mailboxes = Get-Mailbox -ResultSize Unlimited
    foreach ($Mailbox in $Mailboxes)
    {
    $Mailbox | Add-Member -MemberType “NoteProperty” -Name “MailboxSizeMB” -Value ((Get-MailboxStatistics $Mailbox).TotalItemSize.Value.ToMb())
    }
    $Mailboxes | Sort-Object MailboxSizeMB -Desc | Select PrimarySMTPAddress, MailboxSizeMB

    #REM – to export this out — do the following 😉 enjoy (see the part where it says “Select” you can add additional fields like ALIAS etc to this)

    $Mailboxes = Get-Mailbox -ResultSize Unlimited
    foreach ($Mailbox in $Mailboxes)
    {
    $Mailbox | Add-Member -MemberType “NoteProperty” -Name “MailboxSizeMB” -Value ((Get-MailboxStatistics $Mailbox).TotalItemSize.Value.ToMb())
    }
    $Mailboxes | Sort-Object MailboxSizeMB -Desc | Select PrimarySMTPAddress, MailboxSizeMB | Export-Csv -NoType “C:\temp\Mailboxessize.csv”

  2. Thank you for sharing helpful information. It explanation that useful command of displaying mailbox size reports and I also found good information about it from http://www.exchange2010reporting.com/ which allows to generates exchange mailbox size report and export to HTML, CSV, XLS, MHT and RTF formats .

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s