Forum Discussion

IrvanR's avatar
IrvanR
Brass Contributor
Oct 12, 2024
Solved

change the primary address (prefix) distribution list group

change the prefix on the primary address distribution list group how to bulk change primary smtp address distribution list group (before @ / prefix) with powershell? can use csv file?   if possi...
  • Harm_Veenstra's avatar
    Oct 30, 2024

    IrvanR You could use something like:

     

     

    #Install module and connect
    Install-Module ExchangeOnlineManagement
    Connect-ExchangeOnline
    
    #Loop through csv file and change primary smtp
    foreach ($row in Import-Csv -Path C:\data\dl.csv -Delimiter ';') {
        try {
            Set-DistributionGroup -Identity $row.GroupName -PrimarySmtpAddress $row.Email -ErrorAction Stop
            Write-Host ("Updated {0}" -f $row.GroupName)
        }
        catch {
            Write-Warning ("Error updating {0}" -f $row.GroupName)
        }
    }

     

     

    CSV looks like:

    GroupName;Email
    Testdl1;email address removed for privacy reasons
    Testdl2;email address removed for privacy reasons

     

     

Resources