Migrate DistributionGroups to O365 Groups

%3CLINGO-SUB%20id%3D%22lingo-sub-388756%22%20slang%3D%22en-US%22%3ERe%3A%20Migrate%20DistributionGroups%20to%20O365%20Groups%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-388756%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F275686%22%20target%3D%22_blank%22%3E%40PatrickF12%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20tested%20your%20case%20in%20my%20environment%20and%20it%26nbsp%3Bis%20working%20fine.%20May%20be%20PowerShell%20version%20is%20the%20problem%20and%20you%20can%20try%20the%20simple%20alternative%20solution%20like%20below%20and%20it%20will%20add%20individual%20user%20to%20group%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CBLOCKQUOTE%3E%3CP%3Eforeach(%24member%20in%20%24OnPremVerteilerMember)%7B%3CBR%20%2F%3EAdd-UnifiedGroupLinks%20-Identity%20%24NeueO365Gruppe.Identity%20-LinkType%20Members%20-Links%20%24member.PrimarySMTPAddress%3CBR%20%2F%3E%7D%3C%2FP%3E%3C%2FBLOCKQUOTE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-386973%22%20slang%3D%22en-US%22%3ERe%3A%20Migrate%20DistributionGroups%20to%20O365%20Groups%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-386973%22%20slang%3D%22en-US%22%3E%3CP%3EWhat%20is%20not%20working%20exactly%2C%20what's%20the%20error%20message%3F%20While%20you%20can%20add%20multiple%20users%20via%20a%20single%20cmdlet%2C%20you%20will%20have%20to%20parse%20the%20corresponding%20variable%20accordingly%2C%20and%20you%20also%20need%20to%20make%20sure%20that%20the%20group%20identity%20variable%20resolves%20correctly.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20are%20ready-to-use%20scripts%20for%20this%20scenario%20btw%3A%26nbsp%3B%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Ftimmcmic%2FDLConversion%2Fblob%2Fmaster%2Fsrc%2FDLConversion.ps1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Ftimmcmic%2FDLConversion%2Fblob%2Fmaster%2Fsrc%2FDLConversion.ps1%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-386623%22%20slang%3D%22en-US%22%3EMigrate%20DistributionGroups%20to%20O365%20Groups%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-386623%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20everyone%2C%3C%2FP%3E%3CP%3Ei%20don't%20have%20that%20much%20knowledge%20in%20Powershell%20yet%20but%20i%20just%20started%20with%20the%20basics%20and%20now%20im%20needing%20some%20help.I%20really%20would%20appreciate%20it%2C%20if%20anyone%20would%20help%20me.%3C%2FP%3E%3CP%3EMy%20goal%20is%20the%20following%3A%3CBR%20%2F%3EWe%20are%20using%20a%20hybrid%20scenario%20of%20OnPrem%20and%20O365.%3C%2FP%3E%3CP%3EMany%20DistributionGroups%20exists%20in%20local%20Exchange.%3C%2FP%3E%3CP%3EI%20would%20like%20to%20migrate%20them%20to%20Exchange%20Online.%3C%2FP%3E%3CP%3EMy%20first%20approach%20is%20the%20following%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%24OnPremVerteilerlisten%20%3D%26nbsp%3Bget-distributiongroup%20%7C%20Where%20name%20-match%20'Test'%3CBR%20%2F%3EForEach%20(%24OnPremVerteiler%20in%20%24OnPremVerteilerlisten)%20%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%24OnPremVerteilerMember%20%3D%20Get-DistributionGroupMember%20-Identity%20%24OnPremVerteiler.Alias%3CBR%20%2F%3E%3CBR%20%2F%3E%24NeueO365Gruppe%20%3D%20New-UnifiedGroup%20-DisplayName%20%24OnPremVerteiler.DisplayName%20-Alias%20%24OnPremVerteiler.Alias%20-AccessType%20Private%3CBR%20%2F%3E%3CBR%20%2F%3ERemove-DistributionGroup%20-Identity%20%24OnPremVerteiler.Alias%20-Confirm%3A%3CBEI%20bedarf%3D%22%22%3E%3CBR%20%2F%3E%7D%3C%2FBEI%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20one%20reads%20my%20OnPrem%20DistributionGroups%20(for%20testing%20purposes%20just%20where%20name%20match%20%22test%22)%3C%2FP%3E%3CP%3EWhile%20in%20the%20loop%2C%20the%20variable%20%24OnPremVerteiler%20contains%20one%20DG.%3C%2FP%3E%3CP%3EThen%20a%20new%20O365%20Group%20will%20be%20generted%20using%20the%20DisplayName%20and%20Alias%20from%20the%20OnPrem%20Group.%3C%2FP%3E%3CP%3EThis%20is%20working%20already.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20i%20additionally%20want%20to%20achive%20is%2C%20that%20the%20members%20(and%20owners)%20from%20every%20OnPrem%20Group%20are%20added%20to%20the%20O365%20Groups.%3C%2FP%3E%3CP%3ETherefore%20i%20startet%20trying%20out%20with%20the%20line%3A%3C%2FP%3E%3CPRE%3E%24OnPremVerteilerMember%20%3D%20Get-DistributionGroupMember%20-Identity%20%24OnPremVerteiler.Alias%3C%2FPRE%3E%3CP%3EThis%20should%20write%20all%20the%20members%20to%20the%20variable%26nbsp%3B%24OnPremVerteilerMember.%3C%2FP%3E%3CP%3EAfter%20that%20i%20tried%20running%20this%3A%3C%2FP%3E%3CPRE%3EAdd-UnifiedGroupLinks%20-Identity%20%24NeueO365Gruppe.Identity%20-LinkType%20Members%20-Links%20%24OnPremVerteilerMember.PrimarySMTPAddress%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUnfortunately%20this%20isn't%20working.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-386623%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-388756%22%20slang%3D%22en-US%22%3ERe%3A%20Migrate%20DistributionGroups%20to%20O365%20Groups%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-388756%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F275686%22%20target%3D%22_blank%22%3E%40PatrickF12%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20tested%20your%20case%20in%20my%20environment%20and%20it%26nbsp%3Bis%20working%20fine.%20May%20be%20PowerShell%20version%20is%20the%20problem%20and%20you%20can%20try%20the%20simple%20alternative%20solution%20like%20below%20and%20it%20will%20add%20individual%20user%20to%20group%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CBLOCKQUOTE%3E%3CP%3Eforeach(%24member%20in%20%24OnPremVerteilerMember)%7B%3CBR%20%2F%3EAdd-UnifiedGroupLinks%20-Identity%20%24NeueO365Gruppe.Identity%20-LinkType%20Members%20-Links%20%24member.PrimarySMTPAddress%3CBR%20%2F%3E%7D%3C%2FP%3E%3C%2FBLOCKQUOTE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-386973%22%20slang%3D%22en-US%22%3ERe%3A%20Migrate%20DistributionGroups%20to%20O365%20Groups%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-386973%22%20slang%3D%22en-US%22%3E%3CP%3EWhat%20is%20not%20working%20exactly%2C%20what's%20the%20error%20message%3F%20While%20you%20can%20add%20multiple%20users%20via%20a%20single%20cmdlet%2C%20you%20will%20have%20to%20parse%20the%20corresponding%20variable%20accordingly%2C%20and%20you%20also%20need%20to%20make%20sure%20that%20the%20group%20identity%20variable%20resolves%20correctly.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20are%20ready-to-use%20scripts%20for%20this%20scenario%20btw%3A%26nbsp%3B%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Ftimmcmic%2FDLConversion%2Fblob%2Fmaster%2Fsrc%2FDLConversion.ps1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Ftimmcmic%2FDLConversion%2Fblob%2Fmaster%2Fsrc%2FDLConversion.ps1%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-469772%22%20slang%3D%22en-US%22%3ERe%3A%20Migrate%20DistributionGroups%20to%20O365%20Groups%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-469772%22%20slang%3D%22en-US%22%3E%3CP%3EBecause%20of%20a%20new%20techcommunity%20account%2C%20this%20is%20just%20a%20short%20response%20to%20follow%20up%20the%20thread.%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Deleted
Not applicable

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.

 

3 Replies

What is not working exactly, what's the error message? While you can add multiple users via a single cmdlet, you will have to parse the corresponding variable accordingly, and you also need to make sure that the group identity variable resolves correctly.

 

There are ready-to-use scripts for this scenario btw: https://github.com/timmcmic/DLConversion/blob/master/src/DLConversion.ps1

@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
}

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