Add Multiple Site Collection Admins
This PnP PowerShell script reads from a CSV file and bulk assigns site collection administrators across multiple SharePoint Online sites in a single operation. It connects to the Tenant Admin Center and iterates through each row, applying the specified admin to the corresponding site.
Purpose
This script helps with tenant-wide admin provisioning by:
- Assigning site collection admins across multiple sites in one run
- Driving bulk provisioning from a simple CSV input file
- Reporting success and failure per site with clear console output
- Reducing manual effort when onboarding admins at scale
Prerequisites
- PnP PowerShell module installed
- Global Administrator or SharePoint Administrator role
- Access to the SharePoint Tenant Admin Center
- CSV file populated with site URLs and admin accounts (see format below)
CSV File Format
The script expects a CSV file with the following two columns:
PowerShell Script
#Parameters
$TenantAdminURL = "https://tenantName-admin.sharepoint.com"
$CSVFilePath = "C:\Path\To\SiteCollectionAdmin.csv"
$ClientId = ¨¨
Try {
#Connect to Admin Center
Connect-PnPOnline -Url $TenantAdminURL -Interactive -ClientId $ClientId
#Get data from the CSV file
$CSVData = Import-Csv $CSVFilePath
#Iterate through each row in the CSV
ForEach($Row in $CSVData)
{
Try{
#Add Site collection Admin
Set-PnPTenantSite -Url $Row.SiteURL -Owners $Row.SiteCollectionAdmin
Write-host "Added Site collection Administrator to $($Row.SiteURL)" -f Green
}
Catch {
write-host -f Yellow "`tError Adding Site Collection Admin to $($Row.SiteURL) :" $_.Exception.Message
}
}
}
Catch {
write-host -f Red "`tError:" $_.Exception.Message
}
Usage Notes
- Update
$TenantAdminURLto match your tenant admin URL - Update
$CSVFilePathto the location of your CSV file on disk - The CSV must have columns named exactly
SiteURLandSiteCollectionAdmin - Use the user's UPN (e.g.
user@tenant.com) in theSiteCollectionAdmincolumn - Test with a small subset of sites before running against the full tenant