
@frob ,
SharePoint Online PowerShell to add a site collection administrator for all site collections:
#Variables for processing
$AdminURL = "https://tenant-admin.sharepoint.com/"
$AdminName = "******@tenant.onmicrosoft.com"
#User Names Password to connect
$Password = Read-host -assecurestring "Enter Password for $AdminName"
$Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $AdminName, $Password
#Connect to SharePoint Online
Connect-SPOService -url $AdminURL -credential $Credential
$Sites = Get-SPOSite -Limit ALL
Foreach ($Site in $Sites)
{
Write-host "Adding Site Collection Admin for:"$Site.URL
Set-SPOUser -site $Site -LoginName $AdminName -IsSiteCollectionAdmin $True
}
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.