Search This Blog

Saturday, 2 June 2012

Exchange Mailbox Size

List Exchange users by mailbox size in Exchange 2007 & 2010

This tip shows you how to query an Exchange mail server to determine users with the largest mailboxes. This is useful if you need to move mailboxes to reduce store size, or find users to ping about reducing their mailbox.

The command to do this is as follows. You can copy-paste this into the Exchange Management Shell on your server:

Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}},ItemCount

And you should get the following output:

DisplayName TotalItemSize(MB) ItemCount
----------- ----------------- ---------
Lastname, Firstname 1934 30959
Lastname, Firstname 1849 40519
Lastname, Firstname 1841 43277
Lastname, Firstname 1770 41790
Lastname, Firstname 1643 43348
Lastname, Firstname 1511 21973
Lastname, Firstname 1500 31290
Lastname, Firstname 1499 34474
Lastname, Firstname 1482 25253
Lastname, Firstname 1468 15313
Lastname, Firstname 1461 20534
Lastname, Firstname 1410 31545
Lastname, Firstname 1396 22245
Lastname, Firstname 1344 24807
Lastname, Firstname 1314 25633
... etc ...

The important column is the second one, TotalItemSize. As you can see the largest mailbox is listed first, and is a whopping 1.9 GB.

The breakdown of the command is as follows. Management Shell uses the powerful Unix pipeline idiom to pass and filter output between commands.

The first command is Get-MailboxStatistics which does pretty much what it sounds like it does.

This output is piped to the Sort-Object command, which orders by the TotalItemSize column in descending order.

The Sort-Object output is then transformed via pipe by the Format-Table command, ft for short. This command gives you control of how the 'table' output will be viewed. In this case it transforms TotalItemSize from bytes to megabytes, which is much easier to grok. It also selects only the columns you want to see.

No comments:

Post a Comment