Count active mailboxes and distribution groups in Exchange
Exchange Management Shell one-liners that count the active user mailboxes, shared mailboxes and distribution groups in an Exchange 2016 organisation.
Infrastructure microsoft exchangeContents
Knowing how many mailboxes are actually in use helps with monitoring an Exchange environment and with capacity planning. These commands, run in the Exchange Management Shell of an Exchange 2016 organisation, give you the numbers.
Active user mailboxes
(Get-Mailbox -ResultSize Unlimited -Filter {(RecipientTypeDetails -eq 'UserMailbox') -and (IsMailboxEnabled -eq $True)}).Count
How it works:
Get-Mailboxreturns mailboxes in the organisation.-ResultSize Unlimitedreturns all of them instead of the first 1,000.-Filter {…}keeps only mailboxes whoseRecipientTypeDetailsisUserMailboxand that are enabled.-eqcompares a property with a value..Countgives the number of mailboxes that match.
Active shared mailboxes
The same filter with a different recipient type:
(Get-Mailbox -ResultSize Unlimited -Filter {(RecipientTypeDetails -eq 'SharedMailbox') -and (IsMailboxEnabled -eq $True)}).Count
Distribution groups
(Get-DistributionGroup -ResultSize Unlimited).Count
Without -ResultSize Unlimited, this command also stops at 1,000 results.
Microsoft’s reference pages for Get-Mailbox and Get-DistributionGroup list the other properties you can filter on.