0

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.

1

2 Answers 2

0

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
0

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:

$credentials=Get-Credential
$URL="https://Company.sharepoint.com"
Connect-PnPOnline -Url $URL -Credentials $credentials
$siteColl=Get-PnPTenantSite 
$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  

$scaColl=Get-PnPSiteCollectionAdmin   
foreach($sca in $scaColl)  
{          
    Add-PnPSiteCollectionAdmin -owners $loginname 
} 
} 

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.