How to count the mailboxes on each Exchange store

This script counts the number of mailboxes on each Exchange store

Script :

Get-MailboxDatabase | `
	Select-Object Name,@{Name="Number of users";Expression={(Get-Mailbox -Database $_.name).Count}} | `
	Out-GridView
<>

Reference

Get-MailboxDatabase
This cmdlet is available only in on-premises Exchange Server 2013.
Use the Get-MailboxDatabase cmdlet to retrieve one or more mailbox database objects from a server or organization.

 

Detailed Description

If you use the Get-MailboxDatabase cmdlet with no parameters, it retrieves information about all mailbox databases in the Exchange organization. If you use the Get-MailboxDatabase cmdlet with the Server parameter, it retrieves information about all mailbox databases on the server that you specify.
The following list describes the properties that are returned in the results.

  • Name Name of the database.
  • Server Server hosting the database.
  • Recovery Specifies whether the new database is designated as a recovery database.
  • ReplicationType Replication type of the database.

You need to be assigned permissions before you can run this cmdlet. Although all parameters for this cmdlet are listed in this topic, you may not have access to some parameters if they’re not included in the permissions assigned to you. To see what permissions you need, see the “Mailbox Database Permissions” section in the Recipients permissions topic.

 

Parameters

Parameter Required Type Description
Server Required Microsoft.Exchange.Configuration.Tasks.ServerIdParameter The Server parameter specifies the name of the server from which to retrieve mailbox database information. If you specify this parameter, the command retrieves information about all of the mailbox databases on the server that you specify.
DomainController Optional Microsoft.Exchange.Data.Fqdn The DomainController parameter specifies the fully qualified domain name (FQDN) of the domain controller that retrieves data from Active Directory.
DumpsterStatistics Optional System.Management.Automation.SwitchParameter The DumpsterStatistics switch specifies that transport dumpster statistics be returned with the database status.
Identity Optional Microsoft.Exchange.Configuration.Tasks.DatabaseIdParameter The Identity parameter specifies a mailbox database. You can use the following values:

  • GUID
  • Distinguished name (DN)
  • Database name

If you have multiple databases with the same name, the command retrieves all databases with the same name in the specified scope.

IncludePreExchange2013 Optional System.Management.Automation.SwitchParameter The IncludePreExchange2013 switch parameter specifies whether to return information about the mailbox databases that reside on computers running Microsoft Exchange Server 2013 and earlier versions of Exchange.
Status Optional System.Management.Automation.SwitchParameter The Status switch specifies whether to retrieve the available free space in the database root and information about the following attributes:

  • BackupInProgress
  • Mounted
  • OnlineMaintenanceInProgress

You don’t need to specify a value with this switch.

If you specify this switch, you should format the output in such a way that you can view the additional attributes, for example, pipe the output to the Format-Listcmdlet.

Get-Mailbox
This cmdlet is available in on-premises Exchange Server 2013 and in the cloud-based service. Some parameters and settings may be exclusive to one environment or the other.
Use the Get-Mailbox cmdlet to view mailbox objects and attributes, populate property pages, or supply mailbox information to other tasks.

 

Detailed Description

The Get-Mailbox cmdlet retrieves the attributes and objects for a mailbox. No parameters are required. If the cmdlet is used without a parameter, all mailboxes in the organization are listed.

Note:
To accurately evaluate the current storage quota status using the Get-Mailbox cmdlet, you must look at the UseDatabaseQuotaDefaults property in addition to the ProhibitSendQuota, ProhibitSendReceiveQuota, and IssueWarningQuota properties. A value of True for the UseDatabaseQuotaDefaults property means that the per-mailbox settings are ignored and the mailbox database limits are used. If this property is set to True and the ProhibitSendQuota, ProhibitSendReceiveQuota, and IssueWarningQuota properties are set to unlimited, the mailbox doesn’t have unlimited size. Instead, you must reference the mailbox database storage limits to see what the limits for the mailbox are. A value of False for the UseDatabaseQuotaDefaults property means that the per-mailbox settings are used.

You need to be assigned permissions before you can run this cmdlet. Although all parameters for this cmdlet are listed in this topic, you may not have access to some parameters if they’re not included in the permissions assigned to you. To see what permissions you need, see the “Recipient Provisioning Permissions” section in the Recipients permissions topic.

 

Parameters

Parameter Required Type Description
AccountPartition Optional Microsoft.Exchange.Configuration.Tasks.AccountPartitionIdParameter This parameter is reserved for internal Microsoft use.
Anr Optional System.String The Anr parameter specifies a string on which to perform an ambiguous name resolution (ANR) search. You can specify a partial string and search for objects with an attribute that matches that string. The default attributes searched are:

  • CommonName (CN)
  • DisplayName
  • FirstName
  • LastName
  • Alias
Arbitration Optional System.Management.Automation.SwitchParameter This parameter is available only in on-premises Exchange 2013.The Arbitration parameter specifies that the mailbox for which you are executing the command is an arbitration mailbox. Arbitration mailboxes are used for managing approval workflow. For example, an arbitration mailbox is used for handling moderated recipients and distribution group membership approval.
Archive Optional System.Management.Automation.SwitchParameter The Archive parameter specifies whether to return information about the recipient’s archive mailbox.
Credential Optional System.Management.Automation.PSCredential This parameter is available only in on-premises Exchange 2013.The Credential parameter specifies the user name and password to use to access Active Directory.

This parameter requires the creation and passing of a credential object. This credential object is created by using the Get-Credential cmdlet. For more information, see Get-Credential.

Database Optional Microsoft.Exchange.Configuration.Tasks.DatabaseIdParameter This parameter is available only in on-premises Exchange 2013.The Database parameter specifies the database from which to get the mailbox. You can use the following values:

  • GUID of the database
  • Database name

This parameter can’t be used with the Filter parameter.

DomainController Optional Microsoft.Exchange.Data.Fqdn This parameter is available only in on-premises Exchange 2013.The DomainController parameter specifies the fully qualified domain name (FQDN) of the domain controller that retrieves data from Active Directory.
Filter Optional System.String The Filter parameter indicates the OPath filter used to filter recipients.For more information about the filterable properties, see Filterable properties for the -Filter parameter.
Identity Optional Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter The Identity parameter specifies the identity of the mailbox. You can use one of the following values:

  • GUID
  • Distinguished name (DN)
  • Display name
  • Domain\Account
  • User principal name (UPN)
  • LegacyExchangeDN
  • SmtpAddress
  • Alias
IgnoreDefaultScope Optional System.Management.Automation.SwitchParameter This parameter is available only in on-premises Exchange 2013.The IgnoreDefaultScope parameter instructs the command to ignore the default recipient scope setting for the Exchange Management Shell session and use the entire forest as the scope. This allows the command to access Active Directory objects that aren’t currently in the default scope. Using the IgnoreDefaultScope parameter introduces the following restrictions:

  • You can’t use the DomainController parameter. The command uses an appropriate global catalog server automatically.
  • You can only use the DN for the Identity parameter. Other forms of identification, such as alias or GUID, aren’t accepted.
  • You can’t use the OrganizationalUnit and Identity parameters together.
  • You can’t use the Credential parameter.
InactiveMailboxOnly Optional System.Management.Automation.SwitchParameter This parameter is available only in the cloud-based service.The InactiveMailboxOnly parameter specifies the command to return only inactive mailboxes. An inactive mailbox is a mailbox that has been removed or soft-deleted. An inactive mailbox can be recovered for up to 30 days after it’s removed.

This parameter is available only in the cloud-based service.

IncludeInactiveMailbox Optional System.Management.Automation.SwitchParameter This parameter is available only in the cloud-based service.The IncludeInactiveMailbox parameter specifies the command to return both active and inactive mailboxes. An inactive mailbox is a mailbox that has been removed or soft-deleted. An inactive mailbox can be recovered for up to 30 days after it’s removed.

This parameter is available only in the cloud-based service.

IncludeSoftDeletedMailbox Optional System.Management.Automation.SwitchParameter This parameter is reserved for internal Microsoft use.
MailboxPlan Optional Microsoft.Exchange.Configuration.Tasks.MailboxPlanIdParameter This parameter is available only in the cloud-based service.The MailboxPlan parameter specifies the command to return mailboxes associated with this mailbox plan. A mailbox plan specifies the permissions and features available to a mailbox user. The mailbox plan name you provide must be included in the service plan for the organization in which this mailbox belongs.
Monitoring Optional System.Management.Automation.SwitchParameter This parameter is available only in on-premises Exchange 2013.The Monitoring parameter specifies a list of mailboxes that have a value of MonitoringMailbox for the RecipientTypeDetails property. Two monitoring mailboxes are automatically created for each mailbox database in your organization: one for monitoring the health of public folders and one for monitoring the health of site mailboxes.
Organization Optional Microsoft.Exchange.Configuration.Tasks.OrganizationIdParameter The Organization parameter is reserved for internal Microsoft use.
OrganizationalUnit Optional Microsoft.Exchange.Configuration.Tasks.OrganizationalUnitIdParameter The OrganizationalUnit parameter specifies an organizational unit (OU) and is used to limit the results. If you use this parameter, you only get mailboxes in the container that you specify. You can use either the OU or the domain name. If you use the OU, you must specify the canonical name of the OU.
PublicFolder Optional System.Management.Automation.SwitchParameter The PublicFolder parameter specifies that the mailbox is a public folder mailbox. Public folder mailboxes are specially designed mailboxes to store the hierarchy and content of public folders. This parameter is required to display information about a public folder mailbox.
ReadFromDomainController Optional System.Management.Automation.SwitchParameter This parameter is available only in on-premises Exchange 2013.The ReadFromDomainController parameter specifies that the user information is read from a domain controller in the user’s domain. If you set the recipient scope to include all recipients in the forest and don’t use this parameter, it’s possible that the user information is read from a global catalog with outdated information. If you use this parameter, multiple reads might be necessary to get the information.

NoteNote:
By default, the recipient scope is set to the domain that hosts your servers that run Exchange.
RecipientTypeDetails Optional Microsoft.Exchange.Data.Directory.Recipient.RecipientTypeDetails[] The RecipientTypeDetails parameter specifies the type of recipients returned. Recipient types are divided into recipient types and subtypes. Each recipient type contains all common properties for all subtypes. For example, the type UserMailbox represents a user account in Active Directory that has an associated mailbox. Because there are several mailbox types, each mailbox type is identified by the RecipientTypeDetails parameter. For example, a conference room mailbox has RecipientTypeDetails set to RoomMailbox, whereas a user mailbox has RecipientTypeDetails set toUserMailbox.This parameter accepts the following values:

  • RoomMailbox
  • EquipmentMailbox
  • LegacyMailbox
  • LinkedMailbox
  • UserMailbox
  • DiscoveryMailbox
  • SharedMailbox
RemoteArchive Optional System.Management.Automation.SwitchParameter This parameter is available only in on-premises Exchange 2013.The RemoteArchive parameter specifies whether to disconnect the remote archive for this mailbox. A remote archive exists in a cloud-based service.

When you use this parameter, you can’t use the Archive parameter.

ResultSize Optional Microsoft.Exchange.Data.Unlimited The ResultSize parameter specifies the maximum number of results to return. If you want to return all mailboxes that match the query, useunlimited for the value of this parameter. The default value is 1000.
Server Optional Microsoft.Exchange.Configuration.Tasks.ServerIdParameter This parameter is available only in on-premises Exchange 2013.The Server parameter specifies an individual server and is used to limit the results. If you use this parameter, you only get mailboxes that reside on the server that you specify. Use the common name of the server that you want to specify.
SoftDeletedMailbox Optional System.Management.Automation.SwitchParameter This parameter is available only in the cloud-based service.The SoftDeletedMailbox parameter specifies a list of deleted mailboxes that were deleted within the last 30 days.
SortBy Optional System.String The SortBy parameter specifies the attribute by which to sort the results. You can sort by only one attribute at a time. You can sort by the following attributes:

  • Alias
  • Display name
  • Name

The results are sorted in ascending order.

UsnForReconciliationSearch Optional System.Int64 This parameter is reserved for internal Microsoft use.
How to count the mailboxes on each Exchange store

Leave a Reply

Your email address will not be published.