• Home
  • Topics
    • Office 365
    • Teams
    • SharePoint Online
    • Exchange 2019
    • Exchange 2016
    • Exchange 2013
    • Hybrid
    • Certificates
    • PowerShell
    • Migration
    • Security
    • Azure
  • Blog
  • Podcast
  • Webinars
  • Books
  • About
  • Videos
    • Interview Videos
    • How To Guide Videos
  • Subscribe
    • Facebook
    • Twitter
    • RSS
    • YouTube

Practical 365

You are here: Home / Exchange Server / PowerShell One-Liner: Get a Count of Exchange Server Mailboxes Per Database

PowerShell One-Liner: Get a Count of Exchange Server Mailboxes Per Database

July 24, 2017 by Paul Cunningham 10 Comments

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.

1
2
3
4
5
6
7
8
9
[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

Exchange Server Exchange Server, Mailboxes, PowerShell

Comments

  1. Mohamed Magdy says

    April 4, 2019 at 9:06 pm

    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.

    Reply
    • Buster77 says

      May 10, 2019 at 5:16 am

      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

      Reply
  2. Dwayne says

    February 23, 2019 at 1:06 am

    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.

    Reply
  3. Scott S says

    November 16, 2018 at 1:06 pm

    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

    Reply
    • Sam P says

      February 7, 2019 at 12:18 am

      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

      Reply
  4. Kash says

    October 30, 2018 at 9:42 am

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

    Reply
  5. Jon LaBarge says

    October 2, 2018 at 1:56 am

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

    Reply
  6. Wilfred Douglas Peko says

    March 28, 2018 at 8:24 am

    Hi All,

    How do I count external mailboxes and internal mailboxes?

    Reply
    • Paul Cunningham says

      March 28, 2018 at 8:53 am

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

      Reply
  7. n8_sirly says

    July 25, 2017 at 5:57 am

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

    Reply

Leave a Reply Cancel reply

You have to agree to the comment policy.

Recent Articles

  • Changes in Microsoft 365 Apps Channels and Why You Should Care
  • A New Tool to Manage Exchange-related Attributes Without Exchange Server
  • Microsoft Launches Group Ownership Governance Policy
  • Making the Case for Identity Governance in Azure Active Directory
  • Prepare an Office 365 migration plan assessment using PowerShell

Copyright © 2022 Quadrotech Solutions AG · Disclosure · Privacy Policy
Alpenstrasse 15, 6304 Zug, Switzerland