How to grant access to "SharePoint Service Administrator" domain group using PowerShell in SP Online?

It doesn't have a email and i tried with Account ID and name, both didn't work.


2 Answers 2


Use the script below to automatically add user in the domain group -

$AdminURL = "https://domain-admin.sharepoint.com/"
$AdminName = "user.domain.onmicrosoft.com"
$SiteCollURL = "https://domain.sharepoint.com/sites/example"
$SiteCollectionAdmin = "[email protected]"

$SecurePWD = ConvertTo-SecureString "Password" –asplaintext –force 
$Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $AdminName, $SecurePWD 
Connect-SPOService -url $AdminURL -credential $Credential
Set-SPOUser -site $SiteCollURL -LoginName $SiteCollectionAdmin -IsSiteCollectionAdmin $True

I was able to achieve it through PnP Powershell. Below is the PnP powershell script to update "SharePoint Service Administrator" as SCA for all site collections:

Connect-PnPOnline -Url $URL -Credentials $credentials
$loginName = "c:0t.c|tenant|ID Of SharePoint Service Administrator domain group in your tenant" 
foreach($site in $siteColl)
write-host -ForegroundColor Green "Updating SCA for site: " $site.Url  
Connect-PnPOnline -Url $site.Url -Credentials $credentials  

foreach($sca in $scaColl)  
    Add-PnPSiteCollectionAdmin -owners $loginname 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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