All scripts
Microsoft 365 176

Get-SharePointSiteOwnerReport

Lists every SharePoint site collection with its primary and secondary owners, so a site with a single owner who has since left the company gets caught before it becomes an access problem.

Get-SharePointSiteOwnerReport.ps1
<#
.SYNOPSIS
    Reports owners for every SharePoint site collection.

.DESCRIPTION
    Lists the primary owner and secondary site collection administrators
    for every site, so a site relying on a single owner who has since
    left the organization is caught before it becomes an access problem.

.EXAMPLE
    .\Get-SharePointSiteOwnerReport.ps1

.NOTES
    Requires PnP.PowerShell connected to the SharePoint admin site.

.AUTHOR
    Shehryar Hassan
#>

$sites = Get-PnPTenantSite

$report = foreach ($site in $sites) {
    $admins = Get-PnPSiteCollectionAdmin -Connection (Connect-PnPOnline -Url $site.Url -ReturnConnection -Interactive)
    [pscustomobject]@{
        Url          = $site.Url
        Owner        = $site.Owner
        AdminCount   = $admins.Count
        SingleOwner  = $admins.Count -le 1
    }
}

$report | Where-Object SingleOwner | Format-Table -AutoSize
Write-Warning "$(($report | Where-Object SingleOwner).Count) site(s) rely on a single administrator."

Read it before you run it, and test in a safe tenant first.