Using Get-EXORecipient in Powershell

One of the most useful commands in the Exchange Online PowerShell module is Get-EXORecipient, which enables administrators to query and retrieve recipient objects from Exchange Online.

Understanding how to effectively use Get-EXORecipient can significantly enhance your ability to manage and maintain your Exchange Online environment efficiently.

In this post, Meeting Room 365 will quickly explore the various use cases and benefits of the Get-EXORecipient cmdlet, providing detailed instructions on how to authenticate, execute, and handle the results of this powerful tool.

What is the Get-EXORecipient PowerShell Command?

Get-EXORecipient in PowerShell is a cmdlet used to retrieve recipient objects from Exchange Online. It allows administrators to query and return various types of recipients such as mailboxes, mail users, contacts, and groups within an Exchange Online environment.

This cmdlet is useful for managing and filtering recipient data, and facilitates tasks like reporting, auditing, and performing bulk operations on Exchange Online recipients. Here’s the syntax of Get-EXORecipient, including a quick explanation of each parameter:

Get-EXORecipient

[[-Identity] <String>]

[-ExternalDirectoryObjectId <Guid>]

[-Filter <String>]

[-IncludeSoftDeletedRecipients]

[-OrganizationalUnit <String>]

[-PrimarySmtpAddress <String>]

[-Properties <String[]>]

[-PropertySets <PropertySet[]>]

[-RecipientPreviewFilter <String>]

[-RecipientType <String[]>]

[-RecipientTypeDetails <String[]>]

[-ResultSize <Unlimited>]

[-UserPrincipalName <String>]

[<CommonParameters>]

  • Identity: Specifies the unique identifier of the recipient.
  • ExternalDirectoryObjectId: Identifies the recipient by its unique GUID.
  • Filter: Applies a filter to the results based on specified criteria.
  • IncludeSoftDeletedRecipients: Includes recipients that have been soft-deleted in the results.
  • OrganizationalUnit: Limits the search to a specific organizational unit.
  • PrimarySmtpAddress: Searches for a recipient by their primary SMTP email address.
  • Properties: Specifies additional properties to retrieve for the recipient.
  • PropertySets: Retrieves specific sets of properties for the recipient.
  • RecipientPreviewFilter: Applies an advanced filter for previewing recipients.
  • RecipientType: Specifies the type of recipient to retrieve (e.g., UserMailbox, MailContact).
  • RecipientTypeDetails: Further refines the recipient type (e.g., SharedMailbox, RoomMailbox).
  • ResultSize: Limits the number of results returned.
  • UserPrincipalName: Searches for a recipient by their user principal name.

What Can We Use Get-ExoRecipient For?

The Get-EXORecipient command is very simple in nature, but it has a few use cases worth considering, such as the following:

  • Filtering Mailbox Recipients for Reporting: Use Get-EXORecipient to generate a list of all mailbox recipients in the organization, allowing administrators to create detailed reports on user activity, mailbox sizes, and other pertinent mailbox-related information.
  • Managing Distribution Groups: We can also use Get-EXORecipient to identify and manage distribution groups within the organization. This includes listing all distribution groups, adding or removing members, and ensuring that the distribution groups meet organizational policies.
  • Compliance and Auditing: Employ Get-EXORecipient to retrieve specific recipient types or attributes to ensure compliance with organizational policies or regulatory requirements. For instance, identifying all mail-enabled users who have not logged in within the past 6 months for potential deactivation or further investigation.

Requisites to Correctly Use the Get-EXORecipient Cmdlet

To use the Get-EXORecipient cmdlet effectively, you need to ensure the following three key prerequisites are met:

  1. Exchange Online Management Module: You must have the Exchange Online PowerShell module installed on your system. This module provides the necessary cmdlets to manage Exchange Online. You can install it using the PowerShell command Install-Module -Name ExchangeOnlineManagement. This module must be kept updated to ensure compatibility with the latest Exchange Online features and cmdlets.
  2. Appropriate Permissions: You need to have the necessary administrative permissions to run this cmdlet. These permissions are granted through roles such as Exchange Administrator, Global Administrator, or specific recipient management roles in Exchange Online. Without these permissions, you will not be able to execute the cmdlet or access the necessary recipient information.
  3. Authentication: Finally, you need to authenticate to Exchange Online using your Microsoft 365 credentials. This is done using the Connect-ExchangeOnline cmdlet, which establishes a remote session with Exchange Online.

How to Use Get-EXORecipient Cmdlet in 3 Quick Steps

Now that we know what this cmdlet is for, let’s learn how to use Get-EXORecipient in just three quick steps.

Step 1: Authenticate to Exchange Online

Authentication is crucial to establish a secure connection to your Exchange Online environment. Without proper authentication, you cannot execute the Get-EXORecipient cmdlet or any other cmdlet in the module.

So, use the Connect-ExchangeOnline cmdlet to initiate the authentication process. Run the following command:

Connect-ExchangeOnline -UserPrincipalName youremail@meetingroom365.com

Replace youremail@meetingroom365.com with your actual Microsoft 365 or Exchange Online admin account email address. You will be prompted to enter your password, which will log you into the system.

Step 2: Execute the Get-EXORecipient Cmdlet

With the authentication in place, you can now use the Get-EXORecipient cmdlet to retrieve recipient objects from Exchange Online.

If you just need to retrieve all recipients, you can run the basic command:

Get-EXORecipient


This command returns a list of all recipient objects in your Exchange Online organization.

If you want more information, you need to adjust the parameters to match your needs. Take a look at this example:

Get-EXORecipient -Identity james@meetingroom365.com

The output of this command returns the recipient attribute details for the user james@meetingroom365.com.

You can adjust the parameters until you obtain the desired result.

Step 3: Handling and Exporting Results

After retrieving the desired recipient information, you might want to process or export the results for further analysis or reporting purposes.

For example, you can store the results in a variable, filter and manipulate the data to display specific attributes, and export it to a CSV file for use in spreadsheet applications like Excel.

This allows you to efficiently organize, analyze, and share the information, simplifying the process.

Wrapping Up: Managing Exchange Online Mailboxes with Get-EXORecipient

It’s clear that learning how to use the Get-EXORecipient cmdlet in PowerShell is a crucial skill for any IT administrator managing an Exchange Online environment. This versatile cmdlet allows for efficient retrieval and management of various recipient objects, enabling you to perform essential tasks such as generating detailed reports, managing distribution groups, and ensuring compliance with organizational policies.

So, whether you are new to Exchange Online management or looking to enhance your existing skills, understanding and utilizing Get-EXORecipient will empower you to achieve greater efficiency and control in your administrative tasks.