You can use the Exchange Admin Center (EAC) web interface or the Get-Mailbox PowerShell cmdlet to view mailbox information in your Microsoft 365 tenant (Exchange Online) or on-premises Exchange Server organization. In this article, we’ll show you a bunch of useful PowerShell commands with Get-Mailbox to get various information about Exchange mailboxes.
The Get-Mailbox cmdlet is available on the on-premises Exchange Server (2019/2016/2013/2010) organizations and the cloud-based Exchange Online service. Some of the parameters and attributes of the cmdlet may differ slightly depending on the Exchange version.
Let’s start by connecting to Exchange.
If you have an on-premises Exchange Server, you can simply open the Exchange Management Shell (EMS) on a domain-joined computer or server. It will automatically connect to the nearest Exchange Server in your organization.
The Exchange Online PowerShell V3 module (EXO V3) is used to connect to Exchange Online tenant. You can install this module on any computer from the PowerShell Gallery with the command:
Install-Module -Name ExchangeOnlineManagement
Connect to your Microsoft 365 (ex Office 365) tenant:
Connect-ExchangeOnline -UserPrincipalName admin@theitbros.com
Log in with an Exchange Online administrator account using Modern Authentication, and confirm sign-in with Azure MFA.
Get-Mailbox: Display Exchange Mailbox Details with PowerShell
When running without parameters, the Get-Mailbox cmdlet displays the full list of mailboxes in your organization.
Note. By default, the Get-Mailbox cmdlet returns a maximum of 1,000 objects in the results that match your criteria. If you want to display all objects, you need to use the -ResultSize Unlimited parameter:
Get-Mailbox -ResultSize Unlimited
To display information about a single mailbox, run the command:
Get-Mailbox -Identity AlexW@theitbros.com
Hint. One of the following parameters can be specified as Identity: Name, Display Name, Alias, Distinguished Name, Email Address, GUID, SamAccountName, Microsoft 365 User ID, or UserPrincipalName.
The cmdlet will only display a few basic properties of the mailbox. To list all the available attributes of an Exchange mailbox, run:
Get-Mailbox -Identity AlexW@theitbros.com| Format-Table
Exchange mailbox has several dozens of different attributes. To display only certain attributes, the Select-Object cmdlet is used. For example, the following command will list the user’s UPN, SMTP address, mailbox creation date, user region, and mailbox type:
Get-Mailbox -Identity AlexW@theitbros.com | select-object UserPrincipalName, PrimarySMTPAddress, WhenMailboxCreated, UsageLocation, RecipientType
You can export mailbox properties to a CSV file. To do this, add the following pipe to the previous command:
| Export-Csv “C:\PS\mailboxreport.csv” -NoType
You can display information about the quotas of a specific mailbox:
Get-Mailbox -Identity AlexW@theitbros.com | select *quota*
Note. Check our post on how to add or remove SMTP aliases for Exchange Online mailboxes.
To find out the size of the mailbox and the number of items in it, you need to use pipe with the Get-MailboxStatistics cmdlet:
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | select DisplayName,TotalItemSize, ItemCount
Top 10 largest mailboxes:
Get-Mailbox | Get-MailboxStatistics | sort-object totalitemsize –descending | Select-Object displayname, totalitemsize ‑First 10
List shared mailboxes:
Get-Mailbox –ResultSize Unlimited –RecipientTypeDetails SharedMailbox
Additional archive mailboxes:
Get-Mailbox –ResultSize Unlimited –Archive
You can also display the mailbox’s last logon time or last user activity time:
Get-Mailbox -ResultSize Unlimited |Foreach{ Get-MailboxStatistics -Identity $_.UserPrincipalName | Select DisplayName,LastLogonTime,LastUserActionTime}
List of mailboxes active in the last 30 days:
Get-Mailbox -ResultSize Unlimited –RecipientTypeDetails UserMailbox,SharedMailbox | Where {(Get-MailboxStatistics $_.Identity).LastLogonTime -gt (Get-Date).AddDays(-30)} | Sort -Property @{e={( Get-MailboxStatistics $_.Identity).LastLogonTime}} -Descending | Select-Object DisplayName,@{n="LastLogon";e={(Get-MailboxStatistics $_.Identity).LastLogonTime}}
The following command will list inactive Exchange mailboxes (mailboxes placed on Litigation Hold or In-Place Hold before soft-delete):
Get-Mailbox -InactiveMailboxOnly | Format-List Name,DistinguishedName,ExchangeGuid,PrimarySmtpAddress
List soft-deleted mailboxes:
Get-Mailbox -SoftDeletedMailbox | select Name,RecipientTypeDetails,WhenSoftDeleted,IsInactiveMailbox
How to Use Get-EXOMailbox in Exchange Online?
In the new Exchange Online PowerShell module v2, we recommend you use the Get-EXOMailbox cmdlet instead of the Get-Mailbox cmdlet. Get-EXOMailbox allows you to get information about objects and their properties only on Exchange Online (Microsoft 365) tenants.
Get-ExoMailbox is a new and improved version of Get-Mailbox cmdlet, it’s almost doubled in production and you’ll get results much faster. The old Get-Mailbox cmdlet retrieves all object properties on selection, but Get-ExoMailbox returns only a minimal set of attributes. In this example, you can see that one Get-Mailbox object contains 248 attributes, compared to only 15 attributes for the Get-ExoMailbox object:
( Get-Mailbox alexw | Get-Member -MemberType Property).count ( Get-ExoMailbox alexw | Get-Member -MemberType NoteProperty).count
When getting information about hundreds and thousands of mailboxes, you will notice that the performance of Get-ExoMailbox is several times higher.
The Get-ExoMailbox cmdlet returns only the following attributes by default:
- Alias
- DisplayName
- DistinguishedName
- EmailAddresses
- ExchangeVersion
- ExternalDirectoryObjectId
- Guid
- Id
- Identity
- Name
- OrganizationId
- PrimarySmtpAddress
- RecipientType
- RecipientTypeDetails
- UserPrincipalName
If you need to get the value of an additional mailbox attribute, you must specify it in the command using -Properties and/or -PropertySets:
Get-ExoMailbox alexw –Properties Alias, EmailAddresses, IsMailboxEnabled,WhenCreated,MaxSendSize,MaxReceiveSize,office -PropertySets Quota
Get mailbox size in Exchange Online:
Get-ExoMailbox alexw| Get-ExoMailboxStatistics| select DisplayName, TotalItemSize, ItemCount, TotalDeletedItemSize|fl
Find mailboxes with auto-forwarding enabled:
Get-ExoMailbox -ResultSize Unlimited| where {$_.ForwardingAddress -ne $Null} | select DisplayName,ForwardingAddress
Get a list of users who have been granted permission to access a mailbox:
Get-ExoMailbox alexw | Get-ExoMailboxpermission
You can use a server-side filter to get all users with a specific value in mailbox attributes. For example, we need to find mailboxes with a certain value in the Office attribute. To accomplish this task, w’ll use the -Filter option and a PowerShell Boolean expression.
Get-ExoMailbox -Filter {Office -eq "CA4"}