PowerShell Script to Return a List of Mailbox Size for All Users

On several occasions, I’ve been asked to provide a report of mailbox sizes and number of items in a mailbox to a few of my customers who are running either Exchange Server 2007 or 2010. Like most of my blogs, this blog is as much documentation for myself as anything else. That way when I need to provide another one of these reports again in a few months, I’m not trying to figure out how I previously accomplished the task.

The following PowerShell Script creates a text file that contains a list of each users mailbox size for a specific mailbox database. Change the -database parameter to match the mailbox name you want to query.

Open the text file with Excel if additional formatting is needed.

08/06/2014
Posting an update to this blog article since I have recently received a comment about it and this particular blog article is more than three years old.

The following results are from an Exchange 2013 Server and as you can see, the results do indeed include mailbox sizes and the number of items in each unique mailbox (per user) in the specified mailbox database:

mb-size1

As far as the original command goes, if you want the output in a text file and to look just as it does in the PowerShell console, here’s the command I would use today:

mb-size2a

µ

3 Comments

  1. Vibin

    thank a lot man

    Reply
  2. shiva Sharma

    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 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”

    Reply
  3. Mike F Robbins

    I appreciate you taking the time to comment on this article and I have verified that my PowerShell command does indeed return the desired information without adding unnecessary complexity.

    I will post an update at the bottom of the existing article so you can see the results along with an updated PowerShell one-liner since this blog article is more than three years old and isn’t the syntax I would use today.

    Reply

Leave a Reply

%d bloggers like this: