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>
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.