SharePoint Online: Export Site Collection Administrators to a CSV Report

Requirement: Get Site Collection Administrators Report for SharePoint Online.

You must have site collection Admin rights, in order to get existing site collection administrators of a SharePoint Online site through PowerShell!

PowerShell to Get Site Collection Administrators in SharePoint Online and Export to CSV:

If you’re a SharePoint Online administrator, there may be a time when you need to export the site collection administrators from all sites in your environment to a CSV file. E.g., you may need this to document who has access and what sites, or if you need to have a record of site administrators for auditing purposes. This article shows you how to use PowerShell to extract this information and export site collection administrators to a CSV file.

Let’s get site collection admins of all SharePoint Online sites and export them to a CSV report using PowerShell.

#Variables for processing
$AdminCenterURL = ""
Try {
    #Connect to SharePoint Online
    Connect-SPOService -url $AdminCenterURL -Credential (Get-Credential)
    #Get all Site colections
    $Sites = Get-SPOSite -Limit ALL
    $SiteData = @()
    #Get Site Collection Administrators of Each site
    Foreach ($Site in $Sites)
        Write-host -f Yellow "Processing Site Collection:"$Site.URL
        #Get all Site Collection Administrators
        $SiteAdmins = Get-SPOUser -Site $Site.Url -Limit ALL | Where { $_.IsSiteAdmin -eq $True} | Select DisplayName, LoginName

        #Get Site Collection Details
        $SiteAdmins | ForEach-Object {
        $SiteData += New-Object PSObject -Property @{
                'Site Name' = $Site.Title
                'URL' = $Site.Url
                'Site Collection Admins' = $_.DisplayName + " ("+ $_.LoginName +"); "
    #Export the data to CSV
    $SiteData | Export-Csv $ReportOutput -NoTypeInformation
    Write-Host -f Green "Site Collection Admninistrators Data Exported to CSV!"
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red

And the site collection administrators CSV report for all SharePoint Online site collections in the tenant:

sharepoint online get site collection administrators and export to CSV

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

7 thoughts on “SharePoint Online: Export Site Collection Administrators to a CSV Report

  • I’m looking for a similar script to fetch the administrator details for specific site URLs

  • Hello Salaudeen,

    i cant seem to get the script to work, I get the same access denied error after it parses through a couple of sites.

    Processing Site Collection:
    Processing Site Collection:
    Processing Site Collection:
    Error: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

    i have removed the site name from my post..

  • Getting below error:

    Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

  • There’s an error in your script where you set the variable for $AdminURL but call out $AdminCenterURL. Thx.


Leave a Reply