How to Use Get-EXOmailbox in Powershell
Efficiently managing mailboxes in Exchange Online environments is easier with PowerShell cmdlets.
Get-EXOMailbox is a command that allows us to retrieve all the mailbox information we need, enabling audits, attribute management, and greater control over mailboxes.
In today's blog post, we'll learn how to use Get-EXOmailbox in PowerShell by following three easy steps.
What is the Get-EXOMailbox Cmdlet?
Get-EXOMailbox is a PowerShell command used for managing mailboxes in Microsoft Exchange Online, part of the Office 365 suite.
When you run the Get-EXOMailbox command, it retrieves information about mailboxes in your Exchange Online environment. You can use it to get details about individual mailboxes or lists of mailboxes, including details about the mailbox settings, status, permissions, and other configuration details.
This is the syntax of the command:
All of these parameters and switches mean something and alter the final output of the command:
- Anr: Stands for Ambiguous Name Resolution. It's used to search for a mailbox where the provided string may match multiple attributes, such as name, alias, or email address;
- Archive: Retrieves only mailboxes that have an archive;
- Async: Runs the command asynchronously, which is useful for time-consuming operations as it doesn't block the PowerShell session;
- Filter: Applies a query string to filter the mailboxes returned, based on specific criteria (for example, properties like department, location, etc.);
- GroupMailbox: Retrieves only group mailboxes (like those used with Microsoft Teams and Office 365 groups);
- InactiveMailboxOnly: Retrieves only mailboxes that are marked as inactive;
- IncludeInactiveMailbox: Includes both active and inactive mailboxes in the results;
- MailboxPlan: Filters mailboxes based on their mailbox plan;
- Migration: Retrieves mailboxes that are in a migration state;
- OrganizationalUnit: Filters mailboxes based on the organizational unit (OU) they belong to;
- Properties: Specifies additional properties to be included in the output that aren't included by default;
- PropertySets: Retrieves predefined sets of properties, which are collections of related properties for mailboxes;
- PublicFolder: Retrieves only public folder mailboxes;
- RecipientTypeDetails: Filters the results based on specific types of recipient, like user mailboxes, shared mailboxes, etc.;
- ResultSize: Limits the number of results returned. Setting this to 'Unlimited' retrieves all results;
- SoftDeletedMailbox: Retrieves mailboxes that have been soft deleted (marked for deletion but still recoverable).
What Can You Use the Get-ExoMailbox Command For?
Get-EXOMailbox's main goal is to provide us with the info we need to correctly manage user mailboxes. After running the command and retrieving the data you need, you'll be able to perform the following tasks (among others):
- Viewing Mailbox Details: You can use Get-EXOMailbox to view detailed information about individual mailboxes. This includes attributes such as the mailbox size, status, policies applied, and other configuration details. This is useful for routine monitoring and auditing purposes;
- Populating Property Pages in Administrative Tools: The cmdlet can be used to retrieve and display the properties of mailboxes in administrative tools or custom scripts. This is particularly useful for Exchange administrators who need to manage and view mailbox properties regularly;
- Filtering and Sorting Mailboxes: With parameters like -Filter, -Properties, and -RecipientTypeDetails, you can filter and sort mailboxes based on specific criteria. For example, you can retrieve all mailboxes of a particular user type or those that meet certain conditions, such as being larger than a specified size;
- Providing Data for Other Tasks and Scripts: The output of Get-EXOMailbox can be used as input for other tasks or scripts. This is a common practice in automation, where the information about mailboxes is used to perform further actions like mailbox migration, backup, or applying new policies.
Prerequisites to Run Get-EXOMailbox in PowerShell
Before running Get-EXOmailbox in PowerShell, it's important to comply with the following prerequisites:
- Updated PowerShell Version: Make sure you are using the latest PowerShell version, as this command is part of fairly recent cmdlet updates in the PowerShell environment;
- Exchange Online Management Module: For Exchange Online, you need to have the Exchange Online Management Module installed. This module includes the necessary cmdlets to manage Exchange Online, including Get-EXOMailbox. It's available via the PowerShell Gallery and can be installed using the Install-Module -Name ExchangeOnlineManagement command;
- Sufficient User Permissions: You need to have the necessary permissions in your Office 365 (Microsoft 365) tenant. You should be an Exchange Online administrator or have been assigned a role that grants you permissions to view and manage mailboxes (ask Exchange admins for help if you don't have sufficient permissions).
How to Use Get-EXOMailbox in PowerShell
Now that you know what Get-EXOmailbox is for, let's learn how to use it by following three straightforward steps.
Step 1: Connect to Exchange Online PowerShell
First, start by connecting to Exchange Online PowerShell. Open PowerShell on your computer and run the following command:
Use your own Microsoft Account credentials (with admin permissions), and move to the following step.
Step 2: Run the Get-EXOMailbox Command
Now, run the Get-EXOMailbox command. There are different ways to run this command, depending on whether you want to retrieve a few or thousands of mailboxes info.
For example, if you want to retrieve all the mailbox information within an organization, run the following command:
However, the cmdlet can be modified to match specific needs. Let's take a look at the following example:
In this case, the command will return the specified properties for the mailbox "james@meetingroom365.com."
Step 3: Check Out the Command Output
After running the command, you will see a list of all mailboxes in your organization.
The output consists of a summary list you can visualize and retrieve for further use. Remember that Get-EXOmailbox only retrieves info - if you want to make changes, you'd need to use other commands.
Wrapping Up: How to Use Get-EXOmailbox in PowerShell
Get-EXOmailbox is a powerful tool that helps all admins check mailbox attributes in a simple, straightforward way.
From simple tasks like viewing mailbox details to more complex operations such as filtering and sorting through large numbers of mailboxes, Get-EXOMailbox offers flexibility and control in mailbox administration.
Make sure to have sufficient admin permissions before running this cmdlet, and start using it to facilitate your daily administrative tasks.