Browsing Mailbox Databases in Exchange 2007 and 2010

A reader asks whether it is possible to browse through mailbox databases to view the details and statistics of the mailboxes they host on Exchange Server 2007 and 2010.  You might recall this was simple to achieve using the Exchange Server 2003 System Manager tools.

The nearest equivalent feature in the Exchange Management Console is using filters in the Recipient Configuration/Mailboxes section of the console.

However this feature does not expose mailbox statistics such as item count and total size.  For those types of details we can use the Exchange Management Shell instead.

For example, we can view the mailbox databases in the organization.

[PS] C:\>Get-MailboxDatabase

Name                           Server          Recovery        ReplicationType
----                           ------          --------        ---------------
Mailbox Database 1             EXCH2010-TEST   False           None
Mailbox Database 2             EXCH2010-TEST   False           None
Mailbox Database 3             EXCH2010-TEST   False           None
Mailbox Database 4             EXCH2010-TEST   False           None

Or to look at the mailboxes within a given database we can pipe one shell command into another.

[PS] C:\>Get-MailboxDatabase "Mailbox Database 1" | Get-Mailbox -ResultSize 15

Name                      Alias                ServerName       ProhibitSendQuota
----                      -----                ----------       -----------------
Administrator             Administrator        exch2010-test    unlimited
Aisha.Bhari               Aisha.Bhari          exch2010-test    unlimited
Alan.Reid                 Alan.Reid            exch2010-test    unlimited
Alannah.Shaw              Alannah.Shaw         exch2010-test    unlimited
Aldith.Walker             Aldith.Walker        exch2010-test    unlimited
Aleisha.Harrison          Aleisha.Harrison     exch2010-test    unlimited
Alex.Heyne                Alex.Heyne           exch2010-test    unlimited
Alice.Mullins             Alice.Mullins        exch2010-test    unlimited
Alison.Pugh               Alison.Pugh          exch2010-test    unlimited
Alison.Lindsay            Alison.Lindsay       exch2010-test    unlimited
Almaz.Duggan              Almaz.Duggan         exch2010-test    unlimited
Amanda.Watters            Amanda.Watters       exch2010-test    unlimited
WARNING: There are more results available than are currently displayed. To view them, increase the value for the
ResultSize parameter.

We can also look at statistics such as item count and total mailbox size of all mailboxes in a given database.

[PS] C:\>Get-MailboxDatabase "Mailbox Database 1" | Get-MailboxStatistics | Sort totalitemsize -desc | ft displayname, totalitemsize, itemcount

DisplayName                             TotalItemSize                                                         ItemCount
-----------                             -------------                                                         ---------
Administrator                           1.402 GB (1,505,666,188 bytes)                                            72179
EXCH2010-TEST 4FE1F90C-LGU000009        84.46 MB (88,567,215 bytes)                                                2977
EXCH2010-TEST 4FE1F90C-LGU000012        77.23 MB (80,986,155 bytes)                                                2568
EXCH2010-TEST 4FE1F90C-LGU000011        71.99 MB (75,483,699 bytes)                                                2489
EXCH2010-TEST 4FE1F90C-LGU000010        70.77 MB (74,204,704 bytes)                                                2523
EXCH2010-TEST 4FE1F90C-LGU000019        54.73 MB (57,390,302 bytes)                                                1917
EXCH2010-TEST 4FE1F90C-LGU000001        51.48 MB (53,980,482 bytes)                                                1725
EXCH2010-TEST 4FE1F90C-LGU000020        51.15 MB (53,634,243 bytes)                                                1725
EXCH2010-TEST 4FE1F90C-LGU000015        50.92 MB (53,394,939 bytes)                                                1725
EXCH2010-TEST 4FE1F90C-LGU000008        50.69 MB (53,153,806 bytes)                                                1725
EXCH2010-TEST 4FE1F90C-LGU000016        50.68 MB (53,138,572 bytes)                                                1725
EXCH2010-TEST 4FE1F90C-LGU000014        50.62 MB (53,079,853 bytes)                                                1741
EXCH2010-TEST 4FE1F90C-LGU000017        50.58 MB (53,035,273 bytes)                                                1725
EXCH2010-TEST 4FE1F90C-LGU000005        50.53 MB (52,980,645 bytes)                                                1725
EXCH2010-TEST 4FE1F90C-LGU000004        50.35 MB (52,795,218 bytes)                                                1725
EXCH2010-TEST 4FE1F90C-LGU000000        50.31 MB (52,755,053 bytes)                                                1725
EXCH2010-TEST 4FE1F90C-LGU000002        50.06 MB (52,490,485 bytes)                                                1725
EXCH2010-TEST 4FE1F90C-LGU000023        50.05 MB (52,486,337 bytes)                                                1725
EXCH2010-TEST 4FE1F90C-LGU000022        50.03 MB (52,464,722 bytes)                                                1725
EXCH2010-TEST 4FE1F90C-LGU000003        49.87 MB (52,292,132 bytes)                                                1725
EXCH2010-TEST 4FE1F90C-LGU000021        49.75 MB (52,170,805 bytes)                                                1725
EXCH2010-TEST 4FE1F90C-LGU000007        49.6 MB (52,006,854 bytes)                                                 1725
EXCH2010-TEST 4FE1F90C-LGU000024        49.44 MB (51,841,314 bytes)                                                1725
EXCH2010-TEST 4FE1F90C-LGU000018        49.31 MB (51,709,283 bytes)                                                1725
EXCH2010-TEST 4FE1F90C-LGU000006        48.64 MB (50,999,424 bytes)                                                1725
EXCH2010-TEST 4FE1F90C-LGU000013        29.46 MB (30,886,139 bytes)                                                 995

Alternatively, we can take a closer look at the mailbox statistics for one specific mailbox.

[PS] C:\>Get-MailboxStatistics -identity Administrator | fl

RunspaceId              : c3678368-5798-4340-8a0a-ab3f721b1a97
AssociatedItemCount     : 131
DeletedItemCount        : 0
DisconnectDate          :
DisplayName             : Administrator
ItemCount               : 72179
LastLoggedOnUserAccount : DOMAIN\Administrator
LastLogoffTime          :
LastLogonTime           : 1/14/2010 2:19:58 PM
LegacyDN                : /O=TEST ORG/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=ADMINISTRATOR
MailboxGuid             : 9658e261-c681-40ac-ad6d-515791e28203
ObjectClass             : Mailbox
StorageLimitStatus      : BelowLimit
TotalDeletedItemSize    : 0 B (0 bytes)
TotalItemSize           : 1.402 GB (1,505,666,188 bytes)
Database                : Mailbox Database 1
ServerName              : EXCH2010-TEST
DatabaseName            : Mailbox Database 1
MoveHistory             :
IsQuarantined           : False
IsArchiveMailbox        : False
Identity                : 9658e261-c681-40ac-ad6d-515791e28203
MapiIdentity            : 9658e261-c681-40ac-ad6d-515791e28203
OriginatingServer       : exch2010-test.domain.local
IsValid                 : True

One of the common tasks that the Exchange Server 2003 System Manager was used for was exporting lists of mailbox users into CSV format for reporting in Excel. We can still achieve this in the Exchange Management Shell by exporting output to a CSV file.

[PS] C:\>Get-MailboxDatabase "Mailbox Database 1" | Get-MailboxStatistics | Sort totalitemsize -desc | Export-CSV C:\mailboxes.csv

The CSV output is formated correctly for easy import into Microsoft Excel.

As you can see although it may seem less intuitive than the previous method of browsing through a GUI the Exchange Management Shell actually makes it much simpler and easier to gather information about the mailboxes in your organization.

Comments

  1. says

    Tried your method to create a .csv for excel, but it does not work for me (Server-W2K8R2, Exch 2010 – Workstation-WinXP Pro SP3, Excel 2007). I even copied and pasted your line, changing only the database number and the drive to write the file to. Below is a partial of what I get. Strangely enough, it works when I display it. This would be a useful tool for one of my reports, if I can get it to work.

    #TYPE Microsoft.PowerShell.Commands.Internal.Format.FormatStartData
    ClassId2e4f51ef21dd47e99d3c952918aff9cd pageHeaderEntry pageFooterEntry autosizeInfo shapeInfo groupingEntry
    033ecb2bc07a4d43b5ef94ed5a35d280 Microsoft.PowerShell.Commands.Internal.Format.TableHeaderInfo
    9e210fe47d09416682b841769c78b8a3
    27c87ef9bbda4f709f6b4002fa4af63c
    27c87ef9bbda4f709f6b4002fa4af63c
    27c87ef9bbda4f709f6b4002fa4af63c <(followed by about 40 lines of that)

      • says

        No luck. Tried it letter-by-letter and space-by-space, and I still get the same results when I open the csv file. Everything works, but the “export” part of it. I will just use the display listing and go from there. That is still a big help.

        Thanks for your time and assistance.

      • says

        Hi Scott, remove the format-table part of the command, it should work then.

        Get-MailboxDatabase “Mailbox Database 01″ | Get-MailboxStatistics | Sort totalitemsize -desc | Export-Csv C:\mailboxes.csv

        • Mishri Nishad says

          This command will work in this way,

          Get-Mailbox -database “Mailbox Database 01″ | Get-MailboxStatistics | Sort totalitemsize -desc | Export-Csv C:\mailboxes.csv

  2. dan says

    “As you can see although it may seem less intuitive than the previous method of browsing through a GUI the Exchange Management Shell actually makes it much simpler and easier to gather information about the mailboxes in your organization”
    You’ve got to be kidding? We’re now back in the 1980′s days of DOS, CPM and UNIX shell scripting. MS is not helping the everyday SMB sys admin, we’ve really got other things to do than figuring out cryptic scripts.
    Nice work on the actual tutorial, well written and informative, keep it up. :-)

    • Steve says

      “We’re now back in the 1980′s days of DOS, CPM and UNIX shell scripting. MS is not helping the everyday SMB sys admin”

      You mean they’re not doing anything for the system admin who hasn’t learned anything since the ’80s.. The truth is, if you’re running a mail server for 50 people, you’re right – you might not get as much bang for the buck in learning Powershell, and a GUI is more your style, but then again, those small companies are probably migrating to GMAIL or Office365 and hiring a college student to manage it with the web GUI… If you’ve got a large enterprise of 25000 mailboxes, and you are tired of having to point and click at everything all day, and want to automate the mundane tasks, you’ll be MUCH BETTER OFF if you spend a day or so learning EXACTLY those commands described in this post, and learn to leverage them. There are SO MANY things you can do, from automating mailbox moves, doing reports, etc. that you could NEVER do in the old GUI. Besides – Microsoft has given a HUGE opening for someone to come behind (see Quest tools) to write a GUI front end management tool that would far exceed what Microsoft would have written in the first place.

      • Wayne says

        I would politely and respectfully disagree. As a direct and immediately pertinent example, the output generated by the scripts above can produce so much chaff that in turn must be sifted through to arrive at a meaningful report, it makes the process cumbersome and tedious. In contrast, gleaning information from previous versions was as simple as taking a glance.
        Additionally, in the past there were much easier (aka quicker) ways of managing mailboxes and queues – provided as yet another example, it was much easier in earlier versions to free up a mailbox/queue by identifying and removing individual problems (e.g. incorrectly formed and/or corrupted emails).
        With each iteration of Exchange, we see less ease-of-use, and more scattered controls that don’t really help admins – they only seem to obfuscate and intentionally complicate day to day processes.
        I think for most admins, the opinion is that going back to CLI is definitely NOT an advantage for any product – it is a major step backwards, sorry.
        I will say however, that the work presented here is of great benefit for those of us who must endeavor to put up with these unfortunate changes.

      • Amanda Byrne says

        Yes, this is a huge back step, and just explains that much more how ineffective and inefficient Exchange has become. Seriously, displaying mailbox size is pretty basic. We are one of those smaller organizations that you say are “probably going to gmail”. We can’t because of some of the features in Exchange that we utilize. Quite frankly given the IT needs of our organization, I don’t have time to migrate OR learn Exchange Powershell GUI.

        It’s ludicrous for any product to come out with a new version that is more cumbersome, more resource-heavy, but less functional.

        • says

          If features in Exchange are important to your business, but you also want less management overhead, then Office 365 is something you should take a serious look at.

          Other than that, I can only recommend looking at PowerShell as a tool to make your entire IT administration life more efficient (across all Microsoft products – Windows, Windows Server, Exchange, SQL, Lync, Active Directory, Azure, etc etc) and embrace it for the benefits it can provide to you, rather than reject it because of the initial learning curve.

        • Amanda Byrne says

          It still doesn’t change that mailbox size is very basic, necessary information, and this is important functionality that was removed in a new version of the software.

          In my defense, my job IS mostly tackling learning curves, and I’m good at it. But you have to prioritize which learning curves to take on, and it really stinks when you have to tackle a new learning curve just to get functionality you had before.

        • says

          In Exchange 2007/2010/2013 you can still open the properties of a mailbox and see the size info.

          I guess what you’re talking about here is that persistent view of the mailbox sizes when you’re viewing a list of mailboxes in Exchange 2003? Collecting that info adds load to servers. Anything that adds load decreases performance. When you’re talking about software that needs to run well at enormous scale then every minor performance hit you can mitigate is a good thing.

          So just as you need to prioritize things, so do software vendors. This is useful but minor functionality that is still available to us, just not in a way that is detrimental to server performance. We can always write ourselves scripts to save time typing out long-ish commands. Like this one:

          http://exchangeserverpro.com/powershell-script-create-mailbox-size-report-exchange-server-2010/

  3. Julian Milano says

    I agree with Dan. What? Can’t the Exchange GUI run the Powershell commands here to create an easily accessible data output?

    I have to now store all my scripts in text files and recall them when I need them then I have to modify the scripts and see what result I get.

    I do love the 80s, but……………………

    • says

      Hi Julian, I’ve been running a lot of these scripts lately as I work on migration planning. Personally it doesn’t bother me, I like being able to kick off the script and find a nicely formatted CSV file at the end. I get it that not everyone sees it that way.

      The capability is probably there (though the exact steps are beyond me right now) to automate the process such that it collects this data on a scheduled basis and makes it available in a graphical report that you can look at when needed. I’m sure if you dug around some of the PowerShell dedicates blogs and websites you’d see some useful tips along those lines.

      • Steve says

        Yep.. I’ve got 26000 users spread across 5 servers and 104 databases, and I get daily reports on user counts on each server, which servers are filling up, what mailboxes are new each day, how many users have excessive mail counts in the “critical” folders, when each database was last backed up, etc.. all through powershell, delivered to me in email daily. Powershell is AWESOME. You can even build GUIs in PS if you do need something interactive with pull-down menus and pushbuttons.

        • Mark Sprague says

          that’s awesome why don’t you share a few of them ……… really I am serious. Thanks in advance

  4. Richard says

    This works great! Worked the first time! I have different deparments on one database. After the export, I can sort by name, but I cannot get it to include the LDAP field “department”. This would help me GREATLY if I could export and sort by department to send out to the groups to clean up their mailboxes.

    THANKS!

  5. Faisal Khan says

    all worked first time! Nice article.

    How can we reduce the result set of get-mailboxstatistics command as you did with get-mailbox command useing resultsize. i just want to get only top 30 users e.g. and i have noticed that resultsize does not work with get-mailboxstatistics command.

  6. Joe says

    Paul, I noticed in your one PS command that the output showed GB, MB and bytes in () witout using any expressions. The best I am able to do is @{expression={$_.totalitemsize.value.ToMB()};label=”Size(MB)”} which would show MB rounded off (no decimal). How did you achieve this?

  7. DK says

    I get this error, can’t go any further

    PS C:\> Get-MailboxDatabase
    The term ‘Get-MailboxDatabase’ is not recognized as the name of a cmdlet, function, script file, or operable program. C
    heck the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:20
    + Get-MailboxDatabase <<<<
    + CategoryInfo : ObjectNotFound: (Get-MailboxDatabase:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

  8. Mario Canchis says

    Hei Paul

    I´ve got a few questions, which i would like to help me solving:

    Here windows 2k3 exc 2k7 sp1
    get-mailboxstatistics | ft displayname,lastlogontime,storagelimitstatus,servername,{$_.TotalItemSize.Value.ToMB()}

    How can i add the PrimarySmtpAddress to be listed using the ps?
    Besides when export to a txt file; i get the short view, i mean dislpay name: Mario Can…. but not full field for any (storagelimitsstatus servername lastlogontime..etc)

    I would like to use “| Export-Csv c:\test.csv” using the command shown before does not work; but it does in the next command

    Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,ServerName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}} | Export-Csv c:\mailbox_alias1.csv

    Thanks for any advice you can give and specially for your time.

    Regards

  9. Tim says

    Hi Paul, this is the perfect article to get me familiar with the Exchange Powershell and getting some useful info from my Exchange DB. I came here because a user was getting an auto generated e-mail stating that his mailbox was “almost full” and gave him a maximum and current size. I have bought some time by asking him to remove large attachments to e-mails but I am rather stumped by my output csv with the three database quota columns saying unlimited….so what is generating the message?

    Thanks

    • says

      The quota settings on the database will be inherited by any mailbox in that database that is set to inherit quota settings.

      A mailbox can be configured with it’s own quota settings, that override those set on the database.

      So in your case you should look at the properties of the mailbox itself, and examine the storage quotas that are configured for that specific mailbox.

  10. Danny says

    Great article, thanks, I was looking through your site and have not seen articles outlining how to take this Exchange PS script and make it a re-occuring time process. Can you please point me to an article? Thank you.

  11. Mohammed Ahmed says

    Paul,

    Firstly I would like to mention that I am a BIG FAN

    Secondly, you have changed the way I Google issues or information (I am always adding up “PAUL CUNNINGHAM” at the end of any Exchange Server related Search)

    Thank You :)

  12. Abhishek Gupta says

    Hello,

    Above ItemCount and ItemSize include hidden NON_IPM_DATA mesages count .
    How can exclude hidden NON_IPM_DATA mesages from ItemCount .
    While We run Get-MailboxStatistisc & Get-MailboxFolderStatistics.

    Please give me a solution . Its urgent Which is required for my current project.

  13. LoneWolf says

    Is there a way to perform mailbox browsing (or better yet, multi-mailbox searching) on a recovery database versus the live mailbox database?

Leave a Reply

Your email address will not be published. Required fields are marked *