You need to find all site owners across your SharePoint environment for an audit or cleanup task. PowerShell is the fastest way to pull this data, but running the wrong command or missing a parameter can give you incomplete results or errors. This article explains the common mistakes when using PowerShell to list SharePoint site owners and how to write the correct script every time.
Key Takeaways: Avoid These PowerShell Mistakes for SharePoint Owner Reports
- Connect-SPOService -Url: Use the SharePoint admin center URL, not a site collection URL, to establish the correct session.
- Get-SPOSite -Limit All: Without the Limit parameter, the cmdlet returns only the first 200 sites, missing many owners.
- $_.Owner property vs. $_.SiteOwner: The Owner property is the primary site collection admin; the SiteOwner property is the group owner for group-connected sites.
Why PowerShell Owner Lists Can Be Wrong
SharePoint Online stores site owner information in two separate places. A site collection has a primary site collection administrator stored in the Owner property. A Microsoft 365 group-connected team site has an additional group owner stored in the SiteOwner property. When you run a PowerShell script without understanding this split, you may list only the primary admin and miss the group owners who have full control. Another common cause of incomplete lists is the default page limit of 200 sites in the Get-SPOSite cmdlet. If your tenant has more than 200 sites, the script stops early and skips the rest. The mistakes described in this article all stem from not reading the SharePoint Online Management Shell documentation for these specific parameters and properties.
Correct PowerShell Script to List All Site Owners
Before you run any script, install the SharePoint Online Management Shell and connect to your tenant. Open Windows PowerShell as an administrator and run the following commands.
- Install the SharePoint Online Management Shell
RunInstall-Module -Name Microsoft.Online.SharePoint.PowerShelland confirm the installation. This module contains all the cmdlets you need. - Connect to SharePoint Online
RunConnect-SPOService -Url https://yourtenant-admin.sharepoint.com. Replace the URL with your tenant admin center URL, not a site collection URL. You will be prompted for global admin or SharePoint admin credentials. - Retrieve all sites with owners
Run$sites = Get-SPOSite -Limit All -IncludeOwnerSiteOwner. The-Limit Allparameter removes the 200-site default limit. The-IncludeOwnerSiteOwnerparameter ensures the cmdlet returns both the primary admin and the group owner for each site. - Export the owner data to a CSV file
Run the following script to create a clean report:$report = @()
foreach ($site in $sites) {
$report += [PSCustomObject]@{
SiteUrl = $site.Url
PrimaryAdmin = $site.Owner.Email
GroupOwner = $site.SiteOwner.Email
LastContentModifiedDate = $site.LastContentModifiedDate
}
}
$report | Export-Csv -Path C:\Reports\SiteOwners.csv -NoTypeInformation
After the script finishes, open the CSV file in Excel. You will see every site in your tenant with the primary admin email in one column and the group owner email in another. If a site does not have a group owner, the GroupOwner cell will be empty. This is expected for classic sites or communication sites.
Common Mistakes and How to Fix Them
Using the wrong connection URL
A frequent error is connecting to a site collection URL like https://yourtenant.sharepoint.com/sites/marketing instead of the admin center URL https://yourtenant-admin.sharepoint.com. The Connect-SPOService cmdlet requires the admin center URL. Using a site URL returns an authentication error. Fix this by always using the -admin suffix in the URL.
Forgetting the -Limit All parameter
The Get-SPOSite cmdlet defaults to returning only 200 sites. If your tenant has 500 sites, you will see only the first 200 owners. Add -Limit All to the command to retrieve every site. Without this parameter, your report is incomplete and you may miss orphaned sites with no owner.
Confusing Owner with SiteOwner
The Owner property holds the primary site collection administrator, usually a single user. The SiteOwner property holds the owner of the underlying Microsoft 365 group for group-connected sites. If you export only $_.Owner, you will miss the group owner who has full control over the site through the group. Always include both properties in your report.
Running the script without the -IncludeOwnerSiteOwner switch
By default, Get-SPOSite does not return the SiteOwner property. If you omit the -IncludeOwnerSiteOwner switch, the $_.SiteOwner value will be empty for all sites, even if a group owner exists. Add this switch to the command to populate the property correctly.
Not handling sites without a group owner
Communication sites and classic team sites do not have a Microsoft 365 group, so the SiteOwner property is null. If your script tries to call $_.SiteOwner.Email on a null object, it throws an error. Use a conditional check in your loop: if ($_.SiteOwner -ne $null) { $groupOwner = $_.SiteOwner.Email } else { $groupOwner = "N/A" }.
PowerShell Scripts Compared: Basic vs. Complete
| Item | Basic Script | Complete Script |
|---|---|---|
| Connection URL | Site collection URL | Admin center URL with -admin |
| Site limit | Default 200 sites | -Limit All |
| Owner property included | Only Owner | Owner and SiteOwner |
| Group owner switch | Not used | -IncludeOwnerSiteOwner |
| Null handling | Throws error on null | Conditional check for null |
| Output format | On-screen only | CSV export with all columns |
The basic script is fast for a quick check of a few sites but fails for any tenant with more than 200 sites or group-connected sites. The complete script works for any tenant size and produces a reliable report that includes both primary admins and group owners.
You can now run a PowerShell script that lists every site owner in your SharePoint Online tenant without missing a single record. Start by connecting to the admin center URL with the correct credentials, then use Get-SPOSite -Limit All -IncludeOwnerSiteOwner to retrieve all sites. For an advanced tip, add the -Filter parameter to target only sites that have not been modified in the last 90 days, which helps you identify stale sites before removing their owners.