How to Bulk Change Email Domains with Exchange Online PowerShell
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.

- 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.
Ensure you are running PowerShell as an Administrator and possess Global Admin or Exchange Admin privileges in your Microsoft 365 tenant.
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.
Right-click the Windows Start button, select Windows PowerShell (Admin) or Terminal (Admin) to open an elevated session.
Type the command `Install-Module ExchangeOnlineManagement` and press Enter. Accept any prompts to install from the PSGallery.
Run `Connect-ExchangeOnline` and sign in with your Microsoft 365 administrator credentials in the popup window.
Once authenticated successfully, run your `Set-Mailbox` script to bulk update the target users' email domains.

Change Domains via Microsoft 365 Admin Center
If PowerShell issues persist, use the web-based Microsoft 365 admin center as an alternative method to bulk update domains.
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. Visit the official website: Go to the official WPS Office website to access the enterprise or standard installer.
- 2. Download the software: Click on 'Free Download' to get the lightweight installation package.
- 3. Deploy to users: Install WPS Office across your domain devices to provide a powerful, free office suite.

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.




