Forum Discussion

Deleted's avatar
Deleted
Mar 25, 2019

Migrate DistributionGroups to O365 Groups

Hi everyone,

i don't have that much knowledge in Powershell yet but i just started with the basics and now im needing some help.I really would appreciate it, if anyone would help me.

My goal is the following:
We are using a hybrid scenario of OnPrem and O365.

Many DistributionGroups exists in local Exchange.

I would like to migrate them to Exchange Online.

My first approach is the following:

 

$OnPremVerteilerlisten = get-distributiongroup | Where name -match 'Test'
ForEach ($OnPremVerteiler in $OnPremVerteilerlisten)
{
$OnPremVerteilerMember = Get-DistributionGroupMember -Identity $OnPremVerteiler.Alias

$NeueO365Gruppe = New-UnifiedGroup -DisplayName $OnPremVerteiler.DisplayName -Alias $OnPremVerteiler.Alias -AccessType Private

Remove-DistributionGroup -Identity $OnPremVerteiler.Alias -Confirm:<bei Bedarf $false>
}

 

This one reads my OnPrem DistributionGroups (for testing purposes just where name match "test")

While in the loop, the variable $OnPremVerteiler contains one DG.

Then a new O365 Group will be generted using the DisplayName and Alias from the OnPrem Group.

This is working already.

 

What i additionally want to achive is, that the members (and owners) from every OnPrem Group are added to the O365 Groups.

Therefore i startet trying out with the line:

$OnPremVerteilerMember = Get-DistributionGroupMember -Identity $OnPremVerteiler.Alias

This should write all the members to the variable $OnPremVerteilerMember.

After that i tried running this:

Add-UnifiedGroupLinks -Identity $NeueO365Gruppe.Identity -LinkType Members -Links $OnPremVerteilerMember.PrimarySMTPAddress

 

Unfortunately this isn't working.

 

  • Deleted 

    I have tested your case in my environment and it is working fine. May be PowerShell version is the problem and you can try the simple alternative solution like below and it will add individual user to group

     

    foreach($member in $OnPremVerteilerMember){
    Add-UnifiedGroupLinks -Identity $NeueO365Gruppe.Identity -LinkType Members -Links $member.PrimarySMTPAddress
    }

  • PatrickF11's avatar
    PatrickF11
    Steel Contributor

    Because of a new techcommunity account, this is just a short response to follow up the thread. :)

Resources