Supporting an infrastructure containing Exchange servers, which will be the case for most enterprise environments these days. there’s always a requirement to find out how big a users mailbox is at any given time. This is where the Get-MailboxStatistics cmdlet comes in extremely handy!

Useful and my most commonly used Get-MailboxStatistics commands

Get-MailboxStatistics -Identity W.Stocks | ft DisplayName, ItemCount, TotalItemSize, LastLogonTime

DisplayName                                       ItemCount           TotalItemSize                 LastLogonTime
-----------                                       ---------           -------------                 -------------
Will Stocks                                               0           0 MB (0 bytes)          01/01/2017 08:00:00

This command is based on a user’s alias. Running this command returns the storage usage statistics for Will Stocks' mailbox. The standard “Get-MailboxStatistics” command would have simply returned the following, which doesn’t provide a huge amount of useful information:

Get-MailboxStatistics -Identity W.Stocks

DisplayName               ItemCount    StorageLimitStatus                                                 LastLogonTime
-----------               ---------    ------------------                                                 -------------
Will Stocks               0                                                                      01/01/2017 08:00:00

The following command will list all mailboxes on the requested server. Bear in mind that if you have multiple exchange servers in a DAG, you’ll need/want to declare the/an active Exchange Server (use Get-MailboxDatabaseCopyStatus *)

Get-MailboxStatistics -Server PrimaryExchange2013

DisplayName               ItemCount    StorageLimitStatus                                                 LastLogonTime
-----------               ---------    ------------------                                                 -------------
Will Stocks               0                                                                      01/01/2017 08:00:00

If you want to list all mailboxes in a specific database, you can do so by using the -Database switch. If you’re unsure as to what your mailbox databases are called, you can find out by running Get-MailboxDatabase.

Get-MailboxStatistics -Database "MailDB01"

Finally, this command I find myself using fairly frequently. If your AD structure is relatively clean and all users are organised into their correct respective OU’s, this command can be extremely useful. As the example below shows, this could be used to obtain a list of mailboxes within an entire site OU (if you have multiple sites separated out in AD). My favourite part about this particular is that it sorts those mailboxes by size (descending). All you need to do with this command is change “ou=Main Office,dc=test,dc=domain,dc=co,dc=uk” to the FQDN of your required OU.

Get-Mailbox -OrganizationalUnit "ou=Main Office,dc=test,dc=domain,dc=co,dc=uk" -ResultSize Unlimited |
Get-MailboxStatistics | Sort TotalItemSize | ft DisplayName,TotalItemSize,Itemcount

I use this command to find out how big mailboxes are for any users that have been moved into my “Disabled Users” OU.

More commands and in-depth explanations can be found on Microsoft’s TechNet article.