logo
search
Exchange Connection Problems

How to Bulk Change Email Domains with Exchange Online PowerShell

Emma BrownEmma Brown Oct 10, 2026 870 views

Question details

The user needs to resolve Set-Mailbox and Connect-ExchangeOnline errors when attempting to bulk change email domains for multiple Microsoft 365 users via PowerShell.

How to Bulk Change Email Domains with Exchange Online PowerShell
Product
Exchange Online
Device & OS
not provided
Scenario
Administrators are trying to update the email domains for multiple users simultaneously but are encountering command recognition or connection errors in PowerShell.
Observed behavior
Executing Connect-ExchangeOnline or Set-Mailbox commands in PowerShell results in errors, preventing the bulk modification of user email domains.
Before you start

Ensure you are running PowerShell as an Administrator and possess Global Admin or Exchange Admin privileges in your Microsoft 365 tenant.

Solution 1Recommended

Install and Use the Exchange Online Management Module

Install the required Exchange Online Management module to properly authenticate and execute Set-Mailbox commands without errors.

Errors with 'Connect-ExchangeOnline' typically occur when the Exchange Online Management module is missing or outdated. Installing the latest module directly from an elevated PowerShell prompt resolves authentication and command availability issues.

1
Run PowerShell as Administrator

Right-click the Windows Start button, select Windows PowerShell (Admin) or Terminal (Admin) to open an elevated session.

2
Install the module

Type the command `Install-Module ExchangeOnlineManagement` and press Enter. Accept any prompts to install from the PSGallery.

3
Connect to Exchange Online

Run `Connect-ExchangeOnline` and sign in with your Microsoft 365 administrator credentials in the popup window.

4
Execute the Set-Mailbox command

Once authenticated successfully, run your `Set-Mailbox` script to bulk update the target users' email domains.

Install and Use the Exchange Online Management Module
Authentication Successful: Modern authentication is fully supported in the V2 and V3 Exchange Online Management modules.
Free Microsoft Office alternative

Looking for a cost-effective office suite for your newly configured domain users?

While you manage your Exchange domains and Microsoft 365 tenant settings, consider deploying WPS Office for your workforce. It is a free, lightweight, and fully compatible alternative to Microsoft Office, ensuring seamless document management across your organization.

  1. 1. Visit the official website: Go to the official WPS Office website to access the enterprise or standard installer.
  2. 2. Download the software: Click on 'Free Download' to get the lightweight installation package.
  3. 3. Deploy to users: Install WPS Office across your domain devices to provide a powerful, free office suite.
Fully compatible with Microsoft Word, Excel, and PowerPoint formats (.docx, .xlsx, .pptx).Lightweight deployment, ideal for mass distribution across new domain users.Familiar user interface ensuring zero learning curve for employees transitioning from MS Office.Cost-effective enterprise solution with robust PDF editing tools built-in.
microsoft office alternative - wps office

Frequently Asked Questions

Why do I get a 'Connect-ExchangeOnline is not recognized' error?

This error occurs if the Exchange Online Management module is not installed on your system. You must run 'Install-Module ExchangeOnlineManagement' in an elevated PowerShell window before attempting to connect.

Can I change email domains for hundreds of users at once using PowerShell?

Yes. By connecting to Exchange Online via PowerShell, you can import a CSV file containing user details and use a 'ForEach' loop alongside the 'Set-Mailbox' cmdlet to update hundreds of users simultaneously.

Do I need special administrative permissions to change email domains?

Yes, you must be assigned either the Exchange Administrator or Global Administrator role in your Microsoft 365 tenant to modify user mailbox properties and email domains.