After my research and testing, you can use this powershellTto add a user as site collection admin on all site collections in sharepoint 2013.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#User Account to add as Site Collection Admin
$UserAccount="xyza\spsite"
Get-SPSite -Limit "All" | ForEach-Object {
$User = $_.RootWeb.EnsureUser($UserAccount)
if($User.IsSiteAdmin -ne $True)
{
$User.IsSiteAdmin = $True
$User.Update()
Write-Host "Added Site Collection Administrator for Site Collection:" $_.URL -ForegroundColor Green
}
else
{
Write-Host "User is already an Site Collection Administrator for Site Collection:" $_.URL -ForegroundColor Yellow
}
}
The running effect is as follows:
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.