1

Is there a way to add a security group as Primary or secondary site collection administrator to all the sites in the tenant via PowerShell?

I know this works for adding a user account to all the sites as SC Admin

$Sites = Get-SPOSite -Limit ALL
Foreach ($Site in $Sites)
{
Set-SPOUser -site $Site.Url -LoginName $AdminName -IsSiteCollectionAdmin $True

The same command with Set-SPOSiteGroup does not work

Set-SPOSiteGroup : A parameter cannot be found that matches parameter name 'IsSiteCollectionAdmin'

Since 'IsSiteCollectionAdmin' is not accepted with Set-SPOSiteGroup

Any suggestions on how to set security group as site collection administrator via PS script/ cmdlets?

0

You can not add AD security group as Site Collection administrator.

Refer This link.

  • This seems to be really outdated and definitely not for SharePoint Online. – Murilo Santana Aug 21 at 21:22
0

Just tried it here and worked for me. I'm using PNP and assuming you got the Security group ID from Azure AD.

Connect-PNPOnline "https://tenant.sharepoint.com/sites/SiteCollection"
$web = Get-PnPWeb
$azureADGroup = "c:0t.c|tenant|AzureAD-SecurityGroup-ID"
$ensureUser = $web.EnsureUser($azureADGroup)
$user = Get-PnPUser $azureADGroup
Add-PnPSiteCollectionAdmin -Owners $user.LoginName

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.