How to use Get-Mailbox (With Examples)

In this guide, you will learn how to use the get-mailbox command to view Exchange mailboxes and details. The Get-Mailbox cmdlet works with both on-premises Exchange and Exchange online.

Contents

What is Get-Mailbox

Get-Mailbox is a PowerShell cmdlet that retrieves information about mailboxes found in an Exchange organization or Microsoft 365 tenant. This command can be used with on-premises Exchange and Exchange online. It is part of the Exchange Management Shell and is often used in Exchange Server and Exchange Online PowerShell. This cmdlet allows administrators to view the properties of mailboxes, such as their display name, email addresses, mailbox size, or assigned policies. Managing mailboxes efficiently is important for maintaining organizational communication and ensuring compliance with policies.

Get-Mailbox vs Get-ExoMailbox

For administrators managing Microsoft Exchange and Microsoft 365 environments, it is important to know the difference between Get-Mailbox and Get-ExoMailbox. While both do serve the purpose of retrieving mailbox information, they are best used for different environments and use cases.

Note: For exchange online Microsoft recommends using the Get-ExoMailbox cmdlet. In my experience, they both work fine for exchange online.

Get-Mailbox

Get-Mailbox is used for the on-premises Exchange Server or Microsoft 365 environments. (You must be connected to the Online Exchange in PowerShell)

  • Compatibility with On-Premises Exchange and Exchange Online – If you manage only an on-premises environment, this cmdlet is your go-to tool for mailbox management.
  • Familiarity Across Exchange Versions – Supported across multiple versions of Exchange Server and Exchange Online, making it easier to transition between on-premises and cloud environments.
  • Advanced Filtering Options – Includes the ability to use -Filter or -Where-Object to help get a specific mailbox

Get-ExoMailbox

Get-ExoMailboxs is designed specifically for managing mailboxes in Microsoft 365. (You must be connected to the Online Exchange in PowerShell)

  • Performance and Scalability – Designed for high-performance querying, especially in large Exchange Online environments with thousands of mailboxes.
  • Modern Authentication Support – Fully supports Modern Authentication and Multi-Factor Authentication, making it secure for Microsoft 365.
  • Cloud-Specific Features – Includes properties and filters exclusive to Exchange Online, such as MailboxPlan, InPlaceHoldEnabled, LitigationHoldEnabled

Requirements to run Get-Mailbox

  • Permissions – You need to have the appropriate permissions in order to run the Get-Mailbox command. Your account must be an administrator account or have the “Recipient Management” Role.
  • Exchange module – You must have the Exchange Online PowerShell Module installed and be connected in order to run the command. For on-premises Exchange Server, you must have the Exchange Management Shell installed and configured. See the steps below for installing the Exchange Online module.

Install the Exchange Online PowerShell Module 

Install-Module ExchangeOnlineManagement 

Connect to exchange online  

Connect-ExchangeOnline -UserPrincipalName hayden@activedirectorypro.com 

Get-Mailbox Syntax and Parameters

Knowing the syntax of the Get-Mailbox command will make working with Exchange much easier. It will help you to quickly look up mailbox details, troubleshoot and create reports. Below is command syntax and the most commonly used parameters. To view the full syntax, refer to the Get-Mailbox Microsoft document.

Get-Mailbox [-Identity <MailboxIdParameter>] [-RecipientTypeDetails <RecipientTypeDetails>] [-Filter <FilterExpression>] [-ResultSize <Unlimited | [-Anr <String>] [-SoftDeletedMailbox] [-Archive] [-InactiveMailboxOnly] [-IncludeInactiveMailbox] [-Sortby <Property>]

Key Parameters

  • Identity: The Identity parameter specifies the mailbox that you want to view. You can use the following to identity a mailbox.
    • Name
    • Alias
    • Distinguished name (DN)
    • Canonical DN
    • Domain\Username
    • Email address
    • GUID
    • LegacyExchangeDN
    • SamAccountName
    • User ID or user principal name (UPN)
  • RecipientTypeDetails: The RecipientTypeDetails parameter filters the results by the specified mailbox subtype. You can filter on the following Mailbox types.
    • DiscoveryMailbox
    • EquipmentMailbox
    • GroupMailbox (Exchange 2013 or later and cloud)
    • LegacyMailbox
    • LinkedMailbox
    • LinkedRoomMailbox (Exchange 2013 or later and cloud)
    • RoomMailbox
    • SchedulingMailbox (Exchange 2016 or later and cloud)
    • SharedMailbox
    • TeamMailbox (Exchange 2013 or later and cloud)
    • UserMailbox
  • Filter: The filter parameter allows you to create conditions to filter and display specific mailbox information. For example, if you want mailboxes with a specific name, or mailbox size you can use a filter to find this data. See the examples section for filter examples.
  • ResultSize: By default, the get-mailbox command will only return 100 results. To display all results, use this parameter.
  • Anr: The Anr parameter specifies a string on which to perform an ambiguous name resolution (ANR) search. What this means is you can search for a mailbox on a partial name such as display name, UPN or alias.
  • SoftDeletedMailbox: This parameter will return mailboxes that have been soft deleted. Soft delete mailboxes refer to mailboxes that have been deleted but not permanently removed, they are still recoverable.
  • Archive: This parameter will return mailboxes that have the archive mailbox enabled.
  • InactiveMailboxOnly:  Returns only inactive mailboxes. An inactive mailbox is a mailbox that’s placed on Litigation Hold or In-Place Hold before it’s soft-deleted.
  • IncludeInactiveMailbox: Will include inactive mailboxes when you want to view both active and inactive mailboxes.
  • SortBy: Allows you to sort the results on a specific property. For example, you can sort the results by Name, DisplayName, Alias and Office.

Get-Mailbox Examples

Example 1: Retrieve Mailbox Information

Get-Mailbox retrieves information and the properties of mailboxes in your Exchange environment. This command with no parameters will get up to 1000 mailboxes.

Get-Mailbox
get-mailbox cmdlet

Example 2: Get All Mailboxes

If you have over 1000 mailboxes you will need to use the -ResultSize parameter.

Get-Mailbox -ResultSize Unlimited

Example 3: Get Single Mailbox Information

If you want to get information on a single mailbox, use the -identity parameter.

You can use one of the below values to identify the mailbox.

  • Name
  • Alias
  • Distinguished name (DN)
  • Canonical DN
  • Domain
  • Email address
  • GUID
  • LegacyExchangeDN
  • SamAccountName
  • User ID or user principal name (UPN)

In this example, I’ll use a user’s UPN value to look up their mailbox.

Get-Mailbox -identity hayden@activedirectorypro.com 
get single mailbox

Example 4: Get All Information for a mailbox

By default, the get-mailbox cmdlet only displays specific mailbox properties, to display all information use this command. The fl cmdlet is short for format-list, this command will display each property on a separate line.

Get-Mailbox -identity hayden@activedirectorypro.com | fl
get all mailbox properties

Example 5: Get Specific Mailbox Properties

To display only specific information from a mailbox use the select-object parameter followed by the property. In this example I’ll get a list of all mailboxes in the organization and displays only the DisplayName and PrimarySmtpAddress each mailbox.

get-mailbox | select-object DisplayName, PrimarySmtpAddress
specific mailbox properties

Example 6: Get Specific Mailbox Type (User, Shared, Resource, Groups)

To get a specific type of Mailbox you can use the RecipientType parameter. You can use the following values:

  • DiscoveryMailbox
  • EquipmentMailbox
  • GroupMailbox (Exchange 2013 or later and cloud)
  • LegacyMailbox
  • LinkedMailbox
  • LinkedRoomMailbox (Exchange 2013 or later and cloud)
  • RoomMailbox
  • SchedulingMailbox (Exchange 2016 or later and cloud)
  • SharedMailbox
  • TeamMailbox (Exchange 2013 or later and cloud)
  • UserMailbox

Get all User Mailboxes

get-mailbox -RecipientType UserMailbox | select-object DisplayName, RecipientType
user mailboxes

Get all Shared Mailboxes

get-mailbox -RecipientType UserMailbox | select-object DisplayName, RecipientType

Get all Group Mailboxes

get-mailbox -RecipientType GroupMailbox

Example 7: Get All Archived Mailboxes

The command retrieves all mailboxes that have an Archive enabled, including their archived mail data, and it ensures that there is no limit on the number of results returned. This is useful for administrators who need to manage or review all mailboxes with archived content in their organization.

Get-Mailbox -Archive -ResultSize Unlimited 
archive mailboxes

Example 8: Get all Inactive Mailboxes

An inactive mailbox is a mailbox that’s placed on Litigation Hold or In-Place Hold before it’s soft-deleted.

Get-Mailbox -InactiveMailboxOnly

Example 9: Get Shared Mailboxes

This command retrieves all mailboxes that are specifically of the SharedMailbox type, used for shared access by multiple users without requiring individual licenses. This helps administrators manage and view configuration details for shared mailboxes in an Exchange environment. 

Get-Mailbox -RecipientTypeDetails SharedMailbox  
shared mailboxes

Example 10: Get Resource Mailboxes

This retrieves all mailboxes that are designated as RoomMailbox, which are used to manage meeting rooms or other resources in an organization.

Get-Mailbox -RecipientTypeDetails RoomMailbox
room mailboxes

Example 11: Distribution Mailboxes

This command gets information about distribution groups, including their properties, membership, and settings. It allows administrators to manage and view details of groups used to send emails to multiple recipients.

Get-DistributionGroup  

Get-Mailbox Filter Examples

The filter parameter allows you to narrow the results based on specific search criteria.

Let’s look at some examples of using the filter parameter.

Example 1: Filter Mailboxes by DisplayName

This command retrieves all mailboxes who has a DisplayName that contains the text “Hayden”, allowing you to search for and view mailboxes matching that specific name pattern. This does a wildcard string search.

Get-Mailbox -Filter "DisplayName -like '*Hayden*'"
filter mailboxes by displayname

Example 2: Filter by Email Address

This allows administrators to find mailboxes by an email address.

Get-Mailbox -Filter "PrimarySmtpAddress -eq 'user@domain.com'"
filter by email address

Example 3: Filter Mailbox by UserPrincipalName

This is useful for finding mailboxes by the UPN.

Get-Mailbox | Where-Object { $_.UserPrincipalName -eq "hayden@activedirectorypro.com" } 
filter by upn

Example 4: Filter Mailbox by ArchiveStatus

In this example, I’ll find all mailboxes where the ArchveStatus is set to Active.

get-mailbox -filter "ArchiveStatus -eq 'Active'" | select DisplayName, ArchiveStatus
filter by archive status

Conclusion

In conclusion, the Get-Mailbox cmdlet is a powerful tool for managing and retrieving information about mailboxes in Microsoft Exchange Server and Exchange Online environments. It plays an important role in administrative tasks, allowing you to view configuration settings, analyze mailbox properties, and troubleshoot user issues. To use this cmdlet effectively, administrators must ensure they have the necessary permissions and to be connected to the Exchange Online PowerShell module. By understanding Get-Mailbox administrators can enhance their Exchange management capabilities and maintain a well-organized messaging infrastructure.

Related Articles