How to Calculate Exchange 2010 Mailbox Sizes with PowerShell

The Exchange Management Shell, powered by PowerShell, makes it easy to collect size information for the mailboxes in an Exchange 2010 organization.

For example, to list the sizes of all mailboxes on a particular database we can use this command.

[PS] C:\>Get-Mailbox -Database MB-HO-01 | Get-MailboxStatistics | ft displayname,totaldeleteditemsize,totalitemsize

DisplayName      TotalDeletedItemSize    TotalItemSize
-----------      --------------------    -------------
Administrator    0 B (0 bytes)           85.42 KB (87,468 bytes)
Alan Reid        80.08 KB (82,000 bytes) 30.9 MB (32,400,667 bytes)
Alex Heyne       12.35 KB (12,644 bytes) 8.734 MB (9,158,159 bytes)
Aisha Bhari      0 B (0 bytes)           190.4 KB (194,983 bytes)
Aleisha Harrison 0 B (0 bytes)           142.4 KB (145,797 bytes)

If we wanted to know the total size of all of those mailboxes we could output the data to CSV file, import it into Excel, and use formulas to get the results. However that is time-consuming if all you are after is a quick answer.

So instead we can use the Measure-Object command in PowerShell to get the answers we’re looking for. However if we try to use it with the data shown above we’ll get this error.

Measure-Object : Input object "79.95 KB (81,870 bytes)" is not numeric.

So first we need to convert the data into numeric form.

For example, to see the sum, average, minimum and maximum size of the “total item size” for the mailboxes above we run this command.

[PS] C:\>Get-Mailbox -Database MB-HO-01 | Get-MailboxStatistics | %{$_.TotalItemSize.Value.ToMB()} | Measure-Object -sum
 -average -max -min

Count    : 5
Average  : 7.6
Sum      : 38
Maximum  : 30
Minimum  : 0
Property :
About Paul Cunningham

Paul is a Microsoft Exchange Server MVP and publisher of Exchange Server Pro. He also holds several Microsoft certifications including for Exchange Server 2007, 2010 and 2013. Connect with Paul on Twitter and Google+.

Comments

  1. Is it possible to get same information about Archive Mailboxes?

  2. Joakim Razafimanantsa says:

    Very helpful, but how can I do if I want the total size of AvailableNewMailboxSpace on all DB?
    Thank you

  3. Joe Olivarez says:

    You’re initially selecting totaldeleteditemsize and totalitemsize, but in the final command you’re only calculating totalitemsize. Can you explain?

  4. Out of laziness, can I change the parameter to show measurement in MB?

  5. How would I add a line to gather the users extension in exchange unified messaging?

  6. Is it possible to get this information but instead of seeing the display name, see the email address of the FQDN or something similar?

    I’m setting up a hosted exchange and i will have multiple DisplayNames that are the same.

    • This part of the command determines the attributes that are displayed in the output.

      ft displayname,totaldeleteditemsize,totalitemsize

      So you can just change that to display any attribute you wish.

Leave a Comment

*

We are an Authorized DigiCert™ SSL Partner.
Loading...

Still running Exchange 2003? Time to get moving and start your upgrade. Find out how - Click Here