How to Bulk Change Distribution List SMTP Addresses with PowerShell
Question details
The user wants to automate the process of updating SMTP address prefixes for multiple distribution lists using Exchange Online PowerShell and a CSV file.

- Product
- Exchange Online
- Device & OS
- not provided
- Scenario
- An IT administrator needs to execute a bulk update on group email addresses without manually editing each distribution list in the Exchange Admin Center.
- Observed behavior
- Currently, bulk updating distribution list email addresses requires scripting knowledge to process a list of targets and apply new SMTP configurations safely.
Verify that you have Exchange Administrator permissions and confirm whether your distribution lists are cloud-only or synchronized from an on-premises Active Directory, as this dictates where the changes must be applied.
Use Exchange Online PowerShell and a CSV File to Update SMTP Addresses
This method utilizes a structured CSV file and a PowerShell script to safely iterate through distribution lists and update their primary SMTP addresses in bulk.
Before running the script in a production environment, always test it on a small batch of distribution lists to validate the logic. It is highly recommended to retain the previous primary SMTP address as a secondary proxy address so that incoming emails routed to the old address are not lost.
Create a CSV file named UpdateDL.csv with two column headers: 'Identity' (the current email address or alias of the distribution list) and 'NewPrefix' (the desired new email prefix).
Open PowerShell as an Administrator and connect to your Microsoft 365 tenant by executing the command: Connect-ExchangeOnline.
Load your prepared CSV file into a variable by running: $dlList = Import-Csv -Path 'C:\path\to\UpdateDL.csv'.
Write a foreach loop to process each row: foreach ($dl in $dlList) { $newEmail = $dl.NewPrefix + '@yourdomain.com'; Set-DistributionGroup -Identity $dl.Identity -PrimarySmtpAddress $newEmail }.
After the script completes, use Get-DistributionGroup to check a few of the updated lists and perform a test email send to ensure mail flow remains uninterrupted.

Manage Your Administrative CSV Files with WPS Office
While bulk updating Exchange distribution lists requires PowerShell, you can easily prepare, edit, and format your deployment CSV files using WPS Spreadsheet. WPS Office is a free, lightweight, and highly compatible alternative to Microsoft Office.
- 1. Download WPS Office: Visit the official WPS website to download and install the free WPS Office suite.
- 2. Open WPS Spreadsheet: Launch WPS Spreadsheet from the main workspace to handle data and tables.
- 3. Edit Your CSV: Open or create your PowerShell deployment CSV files with proper column headers and save them without formatting loss.

Frequently Asked Questions
Why am I getting an error that the distribution group cannot be modified?
This error typically occurs if the distribution list is synchronized from an on-premises Active Directory. In a hybrid environment, group attributes must be modified in the local AD and allowed to sync to Exchange Online.
How do I keep the old SMTP address so the distribution list still receives emails?
When updating the Primary SMTP Address via PowerShell, ensure your script appends the old email address to the EmailAddresses property as a secondary SIP/SMTP proxy address instead of overwriting the array entirely.
Can I test the PowerShell script without actually changing the email addresses?
Yes. You can append the -WhatIf parameter to the Set-DistributionGroup cmdlet in your script. This will simulate the command execution and output exactly what would happen without applying any actual changes.
What permissions do I need to run these Exchange Online PowerShell commands?
You need to be assigned either the Exchange Administrator role or the Global Administrator role within your Microsoft 365 tenant to modify distribution list properties via PowerShell.




