Counting Exchange Server 2010 Mailboxes with PowerShell

For an Exchange administrator there are a lot of different situations in which they may need to know how many mailboxes are in the organization.  Fortunately this is made easy in Exchange Server 2010 with a few simple PowerShell commands.

To get a count of all mailboxes in the Exchange 2010 organization use the following command:

[PS] C:\>(Get-Mailbox).count
393

Note that if you know your organization has over 1000 mailboxes you need to make sure that the result size of the command output is not limited.

[PS] C:\>(Get-Mailbox -resultsize unlimited).count
393

Next, we can get a count of mailboxes per Exchange 2010 mailbox server.

[PS] C:\>Get-Mailbox | Group-Object -Property:ServerName | Select-Object name,count

Name                                 Count
----                                 -----
esp-br-ex2010                           23
esp-ho-ex2010b                         370

We can also get a count of mailboxes per database in the Exchange organization.

[PS] C:\>Get-Mailbox | Group-Object -Property:Database | Select-Object name,count

Name                                    Count
----                                    -----
MB-BR-01                                   23
MB-HO-01                                  192
MB-HO-02                                  178

As you can see the Group-Object command allows us to see a count of mailboxes based on different attributes or properties of the mailbox. For example a count of mailboxes that are and are not exempt from email address policies.

[PS] C:\>Get-Mailbox | Group-Object -Property:EmailAddressPolicyEnabled | Select-Object name,count

Name                                    Count
----                                    -----
True                                      392
False                                       1

And as a final example, a count of mailboxes by Office (notice that the 6 mailboxes with a null value are still included in the results).

[PS] C:\>Get-Mailbox | Group-Object -Property:Office | Select-Object name,count

Name                                         Count
----                                         -----
Branch Office                                   23
                                                 6
Head Office                                    364
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. So how do you handle multiple domains? These commands appear to only return counts of the users in 1 domain.

  2. Lawrence James says:

    you can also set your adserversettings to view the enitre forest:

    Set-ADServersettings -ViewEntireForest:$true

  3. there is an option to count mailboxes with Get-MailboxDatabase -Status syntax ?

  4. Really simple but very useful.

  5. Kishore Bitra says:

    Hi Paul,

    It’s nice.

  6. Paul

    I’m getting the following error… Please correct If I’m doing wrong

    [PS] C:\Windows\system32>(Get-Mailbox) .count
    Unexpected token ‘.count’ in expression or statement.
    At line:1 char:21
    + (Get-Mailbox) .count <<<(Get-Mailbox -ResultSize unlimited) .count
    Unexpected token ‘.count’ in expression or statement.
    At line:1 char:43
    + (Get-Mailbox -ResultSize unlimited) .count <<<<
    + CategoryInfo : ParserError: (.count:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

  7. Simply Cool one… :)

  8. Paul, hopefully this is not a silly question, but does this count also include detached mailboxes? if so, it there a filter to only include active mailboxes?

  9. Paul,
    Really appriciate if you could answer this question.
    I need to know is it possible to get Mailbox Count using WMI query in Exchange 2010? if yes how?

    • Probably not. I’ve never seen anyone do it that way, thats for sure. Why not just use the PowerShell cmdlets that are built for this purpose? They’re quite easy to use.

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