SharePoint Server: Add Site Collection Administrator to All Sites using PowerShell
Site collection administrators have God-like power within a Site Collection in SharePoint 2016. Apart from Primary and Secondary site collection administrators, we can add additional site collection administrators on any SharePoint site collection. When managing SharePoint sites, adding or removing site collection administrators is often necessary. This can be a time-consuming process if you need to do it for each site individually. This blog post will show you how to use PowerShell to add a site collection administrator to all sites in your SharePoint environment.
How to Add a Site Collection Administrator in SharePoint 2016?
To add a Site Collection Administrator, follow these steps:
- Site Settings Gear >> Click on “Site Settings” Menu Item
- Click on the “Site collection administrators” link under “Users and Permissions”
- Enter the New user in Site Collection Administrators Field. Click OK to save your changes.
OK! Now, How about adding the same user as an administrator in all site collections?
PowerShell Script to Add a Site Collection Administrator to All Site Collections in SharePoint:
If you manage multiple SharePoint sites, adding a site collection administrator to them can be helpful. This can be done quickly and easily with PowerShell.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#User Account to add as Site Collection Admin
$UserAccount="Crescent\Salaudeen"
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
}
}
To add your account to all SharePoint Online sites in the Microsoft 365 environment, refer to How to Add Site Collection Admin to All Sites in the Tenant.