When I’m planning Exchange Server migrations or just generally reporting on mailbox stats I use my Get-MailboxReport.ps1 script. But sometimes I just want a quick look at how many mailboxes are hosted on each database in the organization. To achieve this we can simply pipe the Get-Mailbox cmdlet into Group-Object.

[PS] C:\>Get-Mailbox | Group-Object -Property:Database | Select-Object Name,Count | Sort-Object Name | Format-Table -Auto

Name Count
---- -----
DB02   212
DB05    59
DB06    47
DB07    60
DB08    58

About the Author

Paul Cunningham

Paul is a former Microsoft MVP for Office Apps and Services. He works as a consultant, writer, and trainer specializing in Office 365 and Exchange Server. Paul no longer writes for Practical365.com.

Comments

  1. Mohamed Magdy

    This command didn’t work for me because all my users are in a child domain not in the same domain level as the server, how could i solve this issue.

    1. Buster77

      I too had the same sub-domain issue and was able to resolve it by 1st running the following cmdlet:

      Set-ADServerSettings -ViewEntireForest $true

      Then run Paul’s cmdlet (include the unlimited switch if necessary):

      Get-Mailbox -ResultSize Unlimited | Group-Object -Property:Database | Select-Object Name,Count | Sort-Object Name | Format-Table -Auto

  2. Dwayne

    We’re using Exchange 2016 on prem…is there a recommended MAX mailbox per database? We’ve tried to maintain a 300 – 500 mailbox count per DB for client impact in the case of a DB loss or DB corruption.

  3. Scott S

    Now that I have this lists of database names and mailbox count. How would do I go about selecting from a subset of the list. that is, data base names. Then find the smallest mailbox count among that subset of databases. End result would be to create a new user mailbox in the correct database subset and place it in the lowest database count.
    thank you

    1. Sam P

      This is what I have used previously:

      $DBS = Get-Mailbox | Group-Object -Property Database | Sort-Object Count;
      $EXCHDB = $DBS[0]

      This gives you the Databases sorted by mailbox count and then you can select the first object in the array which will contain the least

  4. Kash

    How to view the users and its associated databases through cmd command.

  5. Jon LaBarge

    Is there a quick way to tie in get-mailboxstatistics to get the totalitemsize?

  6. Wilfred Douglas Peko

    Hi All,

    How do I count external mailboxes and internal mailboxes?

    1. Avatar photo
      Paul Cunningham

      What are “internal” and “external” mailboxes by your definition?

  7. n8_sirly

    I would make a note that if you’re dealing with over 1000 mailboxes you need to use get-mailbox -resultsize unlimited

Leave a Reply