Forum Discussion

Robert K's avatar
Robert K
Brass Contributor
Aug 18, 2017

Script to add global SP admin to all site collections

In this thread https://techcommunity.microsoft.com/t5/SharePoint/O365-Global-Admin-has-no-access-to-recent-SharePoint-Online-site/m-p/30031#M2542 a script was posted to add a admin user as site owner to each sharepoint online (and office group) site.

 

One key component of this scirpt is the line 

 

$SPOnlineAdminClaim = "c:0-.f|rolemanager|s-1-5-21-XXXXXXXXXX-XXXXXXXXX-XXXXXXXXXX-XXXXXXXXX"

 

to 'create' a admin credential. How is that variable created? Where does this SID (?) comes from? I am global sharepoint online admin and I want to use this script. I tried to use my SID that came from 

 

get-aduser -Identity "sharepointadminX" |  Select-Object -Property SID

and put that SID after 

 

c:0-.f|rolemanager|

but with no luck. 

 

When I tried 

Set-SPOUser -Site "https://contoso.sharepoint.com/sites/TEST-foo" -LoginName "c:0-.f|rolemanager|S-1-5-21-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxx" -IsSiteCollectionAdmin $true

I got the error 'user not existing (raised by: Set-SPOUser)'

 

How do I get this script working?

 

 

Resources