Report · 3 tools

Report site collection administrators for every site

Summary

Lists every site collection in the tenant with its site collection administrators, so you can find sites with no owner, a single owner, or a former employee still holding admin rights. Useful before a migration and in quarterly access reviews.

Implementation

Choose your tool. Your choice is remembered on other samples.

PnP PowerShell
# PnP PowerShell needs your own Entra app registration (see the "Register a PnP PowerShell app" lab)
$clientId = "<client-id>"
Connect-PnPOnline -Url "https://<tenant>-admin.sharepoint.com" -Interactive -ClientId $clientId

$report = foreach ($site in Get-PnPTenantSite -Detailed | Where-Object Template -notlike "REDIRECT*") {
  Connect-PnPOnline -Url $site.Url -Interactive -ClientId $clientId
  $admins = Get-PnPSiteCollectionAdmin | Select-Object -ExpandProperty Email
  [pscustomobject]@{
    Url      = $site.Url
    Title    = $site.Title
    Template = $site.Template
    Admins   = ($admins -join ";")
  }
}
$report | Export-Csv .\site-admins.csv -NoTypeInformation
$report | Where-Object { -not $_.Admins } | Format-Table Url

Prerequisites

  • SharePoint Administrator role
  • PnP PowerShell 2.x with your own app registration, or SPO Management Shell, or CLI for Microsoft 365

Output

CSV with Url, Title, Template and Admins (semicolon separated).

Related answers

Contributors

AuthorRole
Priyanshu UpadhyaySolution Architect, Microsoft 365 and Azure
Disclaimer. These samples are provided as is, without warranty of any kind. Read and test every script in a non-production tenant before you run it, and run reports before any command that changes or deletes data.