Forum Discussion
Fromelard
Mar 30, 2017Iron Contributor
Office 365: Add accounts into the Site collection administrators list via PowerShell and CSOM
To add accounts (group or User) into the SPO SIte collection admin via code, there are 2 possible solutions: Via PowerShell and SPO Admin Really simple case ideal for one shot action, you need t...
Gabriel Smoljar
Jan 09, 2020Brass Contributor
Fromelard This method fails for me with the error "The user does not exist or is not unique". Same with Set-PnPTenantSite and Set-SPOUser as suggested by Mikael Svenson. I tested this on two tenants, one that automatically assigns these roles as site admins for new sites and one that don't and the behavior is the same.
Example code:
Connect-PnPOnline <a href="https://contoso-admin.sharepoint.com" target="_blank">https://contoso-admin.sharepoint.com</a>
Set-PnPTenantSite -Url <a href="https://contoso.sharepoint.com/project" target="_blank">https://contoso.sharepoint.com/project</a> -Owners "c:0-.f|rolemanager|s-1-1-11-11111111-111111-111111-1111"