Exchange Online Distribution List Migration Script

Here is a short little script to migrate an Exchange Online distribution list from one tenant to a new one.

#Connect with source tenant
#Connect with destination tenant
$DL = "distrobutionlist1","distrobutionlist2"
$SourceDomain = ""
$DestinationDomain = ""
foreach($D in $DL){
$List = @()
$List = Get-AzureADGroup -SearchString "$D"
$ListMembers = @()
$ListMembers = Get-AzureADGroupMember -ObjectId $List.ObjectId
$ListMembersUPN = @()
$ListMembersUPN = $ListMembers.UserPrincipalName
New-DistributionGroup -Name $List.DisplayName -Description $List.Description -PrimarySmtpAddress $($List.MailNickName+"@$DestinationDomain")
foreach($ListMemberUPN in $ListMembersUPN){
Add-DistributionGroupMember -Identity $List.DisplayName -Member $ListMemberUPN.replace("$SourceDomain","$DestinationDomain")
view raw DLMigration.ps1 hosted with ❤ by GitHub

6 thoughts on “Exchange Online Distribution List Migration Script

  1. Thanks so much for this , helped me out yesterday , one issue I did find was Duplicate group names due to the Get-AzureADGroup -SearchString , was picking up 365 Groups along with Distribution groups

    Adding the below to Line 16 will filter these out ( only way I could determine 365 groups was using the SPO proxy address )

    $List = $list | ?{$_.proxyaddresses -match ‘.*SPO.*’}

    I also rewrote your script to copy help me Azure AD Security Groups


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s