Reputation: 191
I am trying to add one of office 365 group as a site collection administrator in SharePoint online site through PowerShell or API but I am not getting any solution for this.
i can do it manually from site UI but I want to automate it so looking for Powershell or API.
Upvotes: 0
Views: 2955
Reputation: 316
You can use PnP PowerShell cmdlet Add-PnPSiteCollectionAdmin -owners
.
Reference:https://github.com/pnp/powershell/blob/dev/documentation/Add-PnPSiteCollectionAdmin.md
The things we need to notice is that unlike the documentation said, we need to use the LoginName
like i:0#.f|membership|[email protected]
So for an O365 group, it shall be like c:0o.c|federateddirectoryclaimprovider|<Object ID>
For Security group it shall be like c:0t.c|tenant|<Object Id>
You can get the Object ID for group in Azure AD.
Upvotes: 3