List active Exchange mailboxes in Exchange
List active Exchange mailboxes using PowerShell
If you have been following the wansec blog for some time, you know we like Microsoft Exchange. To find the number of active (users, shared) mailboxes, and distribution lists, you can run a command in the Exchange Management Shell.
List user active mailboxes
As a system administrator in a Microsoft Exchange 2016 cluster, you may want to know the amount of active user mailboxes. This information can be useful for monitoring the usage of your Exchange environment and for making decisions about capacity planning. The command to list all (user) active mailboxes is:
(Get-Mailbox -ResultSize Unlimited -Filter {(RecipientTypeDetails -eq 'UserMailbox') -and (IsMailboxEnabled -eq $True)}).count
Details of the command
This command consists of several parts that work together to retrieve the number of active mailboxes. Let’s break it down:
Get-Mailbox
– This cmdlet retrieves information about mailboxes in the Exchange organization. It can be used to retrieve information about one or more mailboxes.-ResultSize Unlimited
– This parameter is used to retrieve all the mailboxes from the Exchange organization.-Filter
– This parameter is used to filter the mailboxes based on certain criteria. In this case, the filter is used to retrieve only those mailboxes that are of the recipient type “UserMailbox” and are enabled.{(RecipientTypeDetails -eq 'UserMailbox') -and (IsMailboxEnabled -eq $True)}
– The filter is enclosed in curly braces {} and is used to specify the criteria for filtering the mailboxes. The filter searches for mailboxes that have the recipient type “UserMailbox” and are enabled. The-eq
operator is used to compare the value of the property to the specified value..count
– The count property is used to retrieve the number of mailboxes that match the specified filter criteria.
By running this command in the Exchange Management Shell, you will be able to retrieve the number of active mailboxes in your Microsoft Exchange 2016 cluster. This information can be useful for monitoring the usage of your Exchange environment and for making decisions about capacity planning.
List shared active mailboxes
Similarly, to find the find the number of active shared mailboxes in a Microsoft Exchange 2016 cluster, you can run the following command in the Exchange Management Shell:
(Get-Mailbox -ResultSize Unlimited -Filter {(RecipientTypeDetails -eq 'SharedMailbox') -and (IsMailboxEnabled -eq $True)}).count
List active distribution lists
In addition to finding the number of active mailboxes, you can also gather the amount of distribution groups by using the following command:
(Get-DistributionGroup).Count
In conclusion, as a system administrator in a Microsoft Exchange 2016 cluster, you can use the Exchange Management Shell to retrieve important information about the usage and capacity of your environment. These information can assist you in making decisions about capacity planning and monitoring the usage of your Exchange environment.
Check Microsoft documention for more details on both Get-Mailbox and Get-DistributionGroup.