简体   繁体   中英

adding office365 group to Sharepoint site collection administrators thorugh Powershell

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. 可以通过 UI 添加

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|user1@contoso.sharepoint.com

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. 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM