Office 365 Groups from AD Groups

There doesn’t appear to be a method to sync an AD group using AD Connect to the cloud and maintain a dynamic group. You can create Office 365 groups that are dynamic based on user attributes but group membership doesn’t provide unique attributes.

I chose to manually create an Office 365 group with an associated Teams site. I then used Powershell and Excel to manually create the membership.

I created the team through the admin console and added the normal admin users are owners of the group.

Next step was to export users from AD group. Example below would need to path update for the export file. I also chose the All Staff group in this case.

get-adgroupmember "all staff" | get-aduser | select userprincipalname | export-csv c:\users\gwadmin\desktop\staffgroupemails.csv

The next issue was that many users in this file do not have an Office 365 account. I manually sorted and deleted any obviously generic accounts using Excel. I then took the column of data and used the transpose feature to paste all rows as one row of data with each email address in a column. This allowed me to simply save the file as a csv to get the string needed for the next step. Make sure to remove column one if you have included your header.

connect-exchangeonline

Add-UnifiedGroupLinks -Identity "staff" -LinkType Members -Links comma-separated-emails 

Do not enclose the email string in double quotes.