For easier admin of SiteGroups I like to nest Security enabled Mail DistributionGroups from Exchange Online into SP SiteGroups. Sadly we cannot add UnifiedGroups aka “Office365 Groups”.
First connect to Exchange Online with PowerShell and run
PS>Get-DistributionGroup Only the SecurityEnabled DGroups are avilable to add to a SP SiteGroup
Here’s the PS script I used to create the DonkeyKong DistributionGroup:
PS>New-Distributiongroup -name "Donkey Kongs" -alias "DonkeyKongs" -type "security" -primarysmtpaddress "donkeykongs@vaerpn.com" –members admin@vaerpn.com,randy.williams@vaerpn.com,joachim.gjertsen@vaerpn.com
The trick to add this DistGroup to a SP SiteGroup is to use “-primarysmtpaddress” as –LoginName like this:
PS>Add-SPOUser –Group “Administration Visitors” –LoginName donkeykongs@vaerpn.com -Site https://vaerpn.sharepoint.com/sites/github
(See also Part2 – Add Users to SiteGroups, I like to use seperate .csv files)
Run the PS>Get-SPOSiteGroup -Site https://vaerpn.sharepoint.com/sites/github
Notice that the SecurityEnabled Distribution lists only displaying long UID. But in SharePoint it displays friendly.
– Offcourse you can add “normal” Microsoft Online Security Groups, in Cloud or from AD Sync – but these are not possible to mail enable,
Run PS>Get-MsolGroup
References:
Manage Azure AD Using PowerShell