Migrate dynamic distribution group to standard DG in Exchange Online

There is no standard way of migrating an Exchange dynamic distribution group to a standard distribution group.

I used powershell to automate this task.

  • fill the variables with the needed information or via a csv and load the data into powershell
  • List existing members of the dynamic group
  • Save the members to a variable
  • rename the old DG
  • Create the new DG
  • Add the members to the new DG
  • Check the new DG

First connect to Exchange online Powershell

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

Import-PSSession $Session -DisableNameChecking


#Remove-PSSession $Session
#Dynamic distribution group which neede to be migrated
$DG = "Team-Testgroup"
$DynamicDG = Get-DynamicDistributionGroup $DG
#variable which is used to rename the Dynamic distribution group
$NewNameDG = $DG+"-old"


#list the Existing members of the Dynamic DG
Get-Recipient -RecipientPreviewFilter $DynamicDG.RecipientFilter

start-sleep -s 10 

#Save the Members in a Variable
$DGMembers = Get-Recipient -RecipientPreviewFilter $DynamicDG.RecipientFilter

#rename the old Dynamic Distribution Group group name
Set-DynamicDistributionGroup -Identity $DG"-DL@****.onmicrosoft.com" -Name $NewNameDG -DisplayName $NewNameDG -Alias $NewNameDG -PrimarySmtpAddres $NewNameDG"@****.onmicrosoft.com"

Start-Sleep -s 5

#Create a New Distribution Group
New-DistributionGroup -Name $DG -Alias $DG -PrimarySmtpAddress $DG"@domain name"

#Get-DistributionGroup -identity $DG"@****.onmicrosoft.com"
#Get-Mailbox -identity $DG"@****.onmicrosoft.com"

#Adding the DynamicDistributionGroup members into the New Distribution Group
$DGMembers | foreach{Add-DistributionGroupmember $DG –Member $_.Name}

#Verifying the members of the New Distribution Group
Get-DistributionGroupMember $DG 



Leave a Reply

Your email address will not be published. Required fields are marked *