Exchange Connection Problems

How to Bulk Change Primary SMTP Addresses in Microsoft 365

Olivia MillerOlivia Miller Nov 2, 2026 870 views

Question details

The user needs to update the primary SMTP addresses for specific Microsoft 365 users using a CSV file after a new domain was added.

How to Bulk Change Primary SMTP Addresses in Microsoft 365
Product
Microsoft 365
Device & OS
not provided
Scenario
Updating user email domains in bulk via a prepared CSV file without affecting non-targeted users.
Observed behavior
Selected users require new primary SMTP addresses to be successfully assigned via automated commands or batch processes.
Before you start

Ensure you have Exchange Administrator or Global Administrator privileges in Microsoft 365, and verify whether directory synchronization is enabled, as this dictates where the changes must be made.

Solution 1Recommended

Bulk Update SMTP Addresses Using PowerShell and CSV

Use the Exchange Online PowerShell module to read a CSV file and loop through specific users to update their primary SMTP addresses.

This method requires connecting to Microsoft 365 via PowerShell. Ensure your CSV file has clear headers, such as 'CurrentUPN' for the existing address and 'NewUPN' for the target address.

1
Prepare your CSV file

Create and save a CSV file containing only the users that should be updated. Include columns mapping the current User Principal Name to the new primary SMTP address.

2
Connect to Exchange Online

Open an elevated PowerShell window and run the 'Connect-ExchangeOnline' cmdlet to authenticate with your Microsoft 365 administrator credentials.

3
Run the update loop

Execute a script that imports the CSV using 'Import-Csv' and pipes it into a 'ForEach' loop. Inside the loop, use the 'Set-MsolUserPrincipalName' or 'Set-Mailbox' cmdlet to assign the new addresses based on the CSV data.

Bulk Update SMTP Addresses Using PowerShell and CSV
Command Execution Environment: If directory synchronization (writeback) is not enabled, you must run these commands directly against Exchange Online. If you have an active on-premises sync, changes generally need to be made in your on-premises Exchange Management Shell.
Free Microsoft Office alternative

Looking for a Lightweight Office Suite for Your Organization?

While managing Exchange and Microsoft 365 infrastructure, you might also be looking for a cost-effective productivity suite for your users. WPS Office provides a free, lightweight, and familiar alternative to Microsoft Office that is fully compatible with standard document formats.

Fully compatible with Microsoft Word, Excel, and PowerPoint formats (.docx, .xlsx, .pptx)Lightweight installation with fast deployment across enterprise devicesFamiliar user interface ensuring a seamless migration with zero learning curveCost-effective solution to reduce overhead while maintaining robust document capabilities
microsoft office alternative - wps office

Frequently Asked Questions

Can I change the primary SMTP address without changing the User Principal Name (UPN)?

Yes, you can use the Set-Mailbox cmdlet with the EmailAddresses parameter in PowerShell to modify SMTP addresses independently of the UPN, though Microsoft generally recommends keeping them matched for a seamless login experience.

What happens to the old email addresses after a bulk SMTP update?

By default, the previous primary SMTP addresses are kept as secondary proxy addresses (aliases). This ensures that users will continue to receive emails sent to their old domain.

Why are my PowerShell changes reverting or not syncing?

If you are in a hybrid environment with authoritative directory synchronization (Azure AD Connect), you must make the SMTP changes in your on-premises Active Directory. Changes made directly in Microsoft 365 will be overwritten during the next sync cycle.