
Here is a short little script to migrate an Exchange Online distribution list from one tenant to a new one.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Connect with source tenant | |
Connect-AzureAD | |
#Connect with destination tenant | |
Connect-ExchangeOnline | |
$DL = "distrobutionlist1","distrobutionlist2" | |
$SourceDomain = "alexholmeset.blog" | |
$DestinationDomain = "contoso.com" | |
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") | |
} | |
} |
[…] Here is a short little script to migrate an Exchange Online distribution list from one tenant to a new one. — Read on alexholmeset.blog/2022/01/06/exchange-online-distribution-list-migration-script/ […]
LikeLike
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
https://pariswells.com/blog/research/copy-azure-ad-security-groups-and-membership-one-tenancy-to-another
LikeLike
Cool, saw both of your comments. Thanks for improving the script. #SharingIsCaring 🙂
Great work.
LikeLike
Another Item , I was able to build a script to replicate some of the group settings like Delivery Restrictions from Source
https://pariswells.com/blog/research/migrate-distribution-groups-and-members-between-365-tenants-and-settings
LikeLike
Your link is dead. Can you please repost?
LikeLike
Should be fixed , looks like the WordPress plugin had got weird!
LikeLike