https://www.sikich.com

Managing Exchange Online with PowerShell: A Guide to Recipient Management

INSIGHT 4 min read

In today’s interconnected world, efficient management of email communication is crucial for businesses. Microsoft Exchange Online, part of the Microsoft 365 suite, provides a robust platform for email services. As an IT administrator, perhaps you have just completed your migration of your last on-premises mailbox to Exchange Online using a hybrid configuration and you have chosen to shut down the last Exchange server in your environment. As of late 2023 this is now a supported configuration as outlined in this Microsoft article:
https://learn.microsoft.com/en-us/exchange/manage-hybrid-exchange-recipients-with-management-tools

With the shutdown of the Exchange server, the supported method of management of Exchange Online objects is through PowerShell using the RecipientManagement module. In this blog post, we’ll explore the essential PowerShell commands using the RecipientManagement module to continue to manage your Exchange Online environment while maintaining directory synchronization with Microsoft Entra Connect.

Prerequisites

Before diving into the commands, ensure you have the following prerequisites in place:

  • Microsoft 365 Subscription: You need an active Microsoft 365 subscription with Exchange Online licenses.
  • Windows PowerShell or PowerShell Core: Install either Windows PowerShell (for Windows) or PowerShell Core (cross-platform) on your machine.

The Recipient Management Module

The RecipientManagement module offers a set of cmdlets specifically designed for managing recipients in Exchange Online. Let’s explore some of the key commands along with examples:

1. Add-PSSnapin *RecipientManagement

This command loads the RecipientManagement module into your PowerShell session. It’s essential to run this before using other cmdlets from the module. Here’s how you can use it:

Add-PSSnapin *RecipientManagement

2. Set-RemoteMailbox

The Set-RemoteMailbox cmdlet allows you to modify properties of a remote mailbox. For example, you can change the display name, alias, or even assign a license. Here are two examples:

Example 1: Change the display name of a user’s mailbox:

Set-RemoteMailbox -Identity user@example.com -DisplayName "John Doe"

Example 2: Assign a license to a remote mailbox:

Set-RemoteMailbox -Identity user@example.com -LicenseAssignment "ExchangeOnlinePlan1"

Full documentation here: https://learn.microsoft.com/en-us/powershell/module/exchange/set-remotemailbox?view=exchange-ps

3. Get-RemoteMailbox

Use Get-RemoteMailbox to retrieve information about remote mailboxes. You can filter results based on specific criteria, such as organizational unit (OU) or mailbox type. Here are two examples:

Example 1: Get all remote mailboxes in the “Sales” organizational unit:

Get-RemoteMailbox -OrganizationalUnit "Sales"

Example 2: Retrieve mailbox details for a specific user:

Get-RemoteMailbox -Identity user@example.com | Select-Object DisplayName, Alias, PrimarySmtpAddress

Full documentation here: https://learn.microsoft.com/en-us/powershell/module/exchange/get-remotemailbox?view=exchange-ps

4. New-RemoteMailbox

Creating a new remote mailbox is straightforward with New-RemoteMailbox. Specify the user’s details, mailbox type, and other relevant parameters:

Example 1: Create a new remote mailbox for Jane Smith:

New-RemoteMailbox -Name "Jane Smith" -UserPrincipalName jane.smith@example.com -Alias jsmith -PrimarySmtpAddress jane.smith@example.com

Example 2: Create a shared mailbox:

New-RemoteMailbox -Name "Support Team" -Shared

Full documentation here: https://learn.microsoft.com/en-us/powershell/module/exchange/new-remotemailbox?view=exchange-ps

5. Remove-RemoteMailbox

When a user leaves the organization, you can use Remove-RemoteMailbox to disable and remove their mailbox:

Example 1: Disable and remove a user’s mailbox:

Remove-RemoteMailbox -Identity user@example.com -Confirm:$false

Example 2: Remove a shared mailbox:

Remove-RemoteMailbox -Identity "Support Team" -Shared -Confirm:$false

Full documentation here: https://learn.microsoft.com/en-us/powershell/module/exchange/remove-remotemailbox?view=exchange-ps

6. Disable-RemoteMailbox

Temporarily disabling a mailbox without removing it entirely is possible using Disable-RemoteMailbox:

Example 1: Disable a user’s mailbox:

Disable-RemoteMailbox -Identity user@example.com

Example 2: Disable a shared mailbox:

Disable-RemoteMailbox -Identity "Support Team" -Shared

Full documentation here: https://learn.microsoft.com/en-us/powershell/module/exchange/disable-remotemailbox?view=exchange-ps

7. Enable-RemoteMailbox

To re-enable a previously disabled mailbox, use Enable-RemoteMailbox:

Example 1: Re-enable a user’s mailbox:

Enable-RemoteMailbox -Identity user@example.com

Example 2: Re-enable a shared mailbox:

Enable-RemoteMailbox -Identity "Support Team" -Shared

Full documentation here: https://learn.microsoft.com/en-us/powershell/module/exchange/enable-remotemailbox?view=exchange-ps

Conclusion

By using these PowerShell commands, you’ll still be able to manage Exchange Online recipients while using Microsoft Entra Connect to sync your local directory. Remember to test any changes in a non-production environment before applying them to your live system.

Have any questions about Exchange Online recipient management using these PowerShell commands? Please reach out to one of our IT experts at any time!

Author

Craig Schellenberg is a Senior Network Consultant at Sikich that works with businesses to improve their IT. Being detail oriented assists in his ability to design and deploy new solutions as well as troubleshoot complex issues. His primary areas of focus are virtualization and storage on premise (whether through VMware vSphere or Microsoft Hyper-V), Microsoft Cloud services such as Azure and Office 365, Microsoft SQL design and administration, backup/DR/Business Continuance, and network route/switch/firewalls.

Craig holds many certifications including his MCSE (Microsoft Certified Solutions Expert) in Productivity, Messaging, and Cloud Platform and Infrastructure. Craig also holds multiple certifications of his VCP (VMware Certified Professional) including version 3, 4 (Data Center Virtualization), 5 (Data Center Virtualization), 5 (Desktop), Cloud, and 6 (Data Center Virtualization).