If you manage SharePoint Online, sooner or later someone will ask: “Can you send me a list of all SharePoint sites in our tenant?” It sounds simple, but doing this manually from the admin center is slow, error‑prone, and painful when you have hundreds of sites. This is where you can use PowerShell to get a complete, repeatable inventory of all site collections in just a few commands.
In this tutorial, let’s walk through how to get all SharePoint site collections from your tenant using both the SharePoint Online Management Shell and PnP PowerShell, and also see how to filter and export this data to CSV for reporting.
Prerequisites
Before you start, make sure you have a few basics in place.
- You need to be a SharePoint admin (or Global admin) in the tenant.
- Install the SharePoint Online Management Shell module on your machine.
- Install PnP PowerShell (cross‑platform, recommended for modern automation).
- Know your SharePoint Admin Center URL, e.g.
https://yourtenant-admin.sharepoint.com.
You can install the modules from an elevated PowerShell window:
Install-Module -Name Microsoft.Online.SharePoint.PowerShell
Install-Module -Name PnP.PowerShellOnce the prerequisites are installed, you can connect to SharePoint Online.
Connect to SharePoint Online
To work with SharePoint Online, you must first connect to your tenant.
Using SharePoint Online Management Shell
$AdminUrl = "https://yourtenant-admin.sharepoint.com"
Connect-SPOService -Url $AdminUrlThis will prompt you to sign in with your SharePoint admin account.
Using PnP PowerShell
$AdminUrl = "https://yourtenant-admin.sharepoint.com"
Connect-PnPOnline -Url $AdminUrl -InteractiveThe -Interactive switch gives you the standard Microsoft sign‑in prompt with MFA support.
Check out Create a SharePoint Online Site Using PowerShell
Get All SharePoint Site Collections with Get‑SPOSite
The Get‑SPOSite cmdlet comes from the SharePoint Online Management Shell module and is designed to work at the tenant level.
Basic syntax
Get-SPOSite [-Identity] [-Detailed] [-Limit] [-Filter] [-IncludePersonalSite] [-Template] `
[-GroupIdDefined] [-ArchiveStatus] [-DisableSharingForNonOwnersStatus]A few important parameters:
- Identity – URL of a specific site collection.
- Detailed – Returns more properties for each SharePoint site collection.
- Limit – Number of sites to return; use
-Limit Allto retrieve everything. - Filter – Server‑side filter with operators like
-eq,-ne,-like,-notlike. - IncludePersonalSite – Include personal OneDrive sites when set to
$true. - Template – Filter by site template (e.g.,
STS#0,STS#3,SITEPAGEPUBLISHING#0,GROUP#0). - GroupIdDefined –
$truefor sites connected to Microsoft 365 groups. - ArchiveStatus – Filter by archive state (Archived, NotArchived, etc.).
- DisableSharingForNonOwnersStatus – Shows sites where non‑owners cannot share.
Example 1: List all SharePoint Site Collections
By default, Get-SPOSite returns only 200 sites in SharePoint, so you should always set -Limit All for a full inventory.
Connect-SPOService -Url "https://yourtenant-admin.sharepoint.com"
# Get all site collections
Get-SPOSite -Limit AllThis shows you each SharePoint site’s URL, owner, storage details, and more in the console. You can see the exact output in the screenshot below:

Read Get SharePoint Site Members Using PowerShell
Example 2: Get SharePoint Site Detailed Information
For more properties (e.g., sharing settings, last modified date), use -Detailed. This command gives detailed information for the SharePoint site collections.
Get-SPOSite -Detailed
Or
Get-SPOSite -Limit All -DetailedYou may see a warning that -Detailed will be deprecated for bulk enumeration, but it still returns a rich set of properties that are useful for reporting. Here is a screenshot below for your reference.

Example 3: Get a Specific SharePoint Site Collection Details
If you only care about one SharePoint site, use -Identity. This example gives details for the specific SharePoint site url.
Get-SPOSite -Identity https://szg52.sharepoint.com/sites/Marketing -Detailed
Or
$SiteUrl = "https://yourtenant.sharepoint.com/sites/Marketing"
Get-SPOSite -Identity $SiteUrl -DetailedThis is handy when you want to quickly check template, storage usage, or sharing settings for a single SharePoint site. Check the screenshot below for your reference.

Check out Add SharePoint Online List Items Using PnP PowerShell
Filter SharePoint Site Collections with Get‑SPOSite
One of the best things about Get-SPOSite is the filtering capability, especially in larger tenants.
Example 4: Only SharePoint Team Sites (no Microsoft 365 group)
Classic/team sites without a group often use template STS#3. Here is the PowerShell script:
Get-SPOSite -Limit All -Filter { Template -eq "STS#3" } |
Select Url, Template, OwnerYou can see the exact output in the screenshot below:

This returns only those SharePoint sites and shows their URL, template, and owner.
Check out Delete a SharePoint Online Site Using PowerShell
Example 5: SharePoint Sites not Connected to Microsoft 365 groups
To find “standalone” sites that are not group‑connected, you can use the below script:
Get-SPOSite -Limit All -GroupIdDefined $false |
Select Url, Owner, TemplateYou’ll see only sites where there is no underlying Microsoft 365 group.

If you want to display all the SharePoint site collections, set the Limit parameter value to ALL.
Check out Get SharePoint Site Storage Size Using PowerShell
Example 6: Archived SharePoint Sites Only
If you use site archiving, it’s often useful to list only archived sites. This example displays SharePoint sites of a specific archive status.
Get-SPOSite -Limit All -ArchiveStatus "Archived" |
Select Url, Title, ArchiveStatusThis makes it easy to review which sites are archived and decide whether they can be deleted or reactivated. You can see the exact output in the screenshot below:

Read Get the SharePoint Site Owner Using PowerShell
Export SharePoint Site Collections to CSV with Get‑SPOSite
In real‑world scenarios, you rarely just look at site collections on screen — you export them to Excel, share with other teams, or use them for audits.
Example 7: Full tenant inventory to CSV
Here is the complete PowerShell script:
$AdminUrl = "https://yourtenant-admin.sharepoint.com"
$CsvPath = "C:\Temp\SharePointOnline-Sites.csv"
Connect-SPOService -Url $AdminUrl
Get-SPOSite -Limit All -Detailed |
Select Title, Url, Owner, Template, StorageUsageCurrent, StorageQuota, `
LastContentModifiedDate, SharingCapability |
Export-Csv -Path $CsvPath -NoTypeInformation -Encoding UTF8This gives you a clean CSV with key properties for every site collection in your tenant.
Read Enable Item-level Permissions in a SharePoint Document Library Using PowerShell
Get all SharePoint Site Collections Using PnP PowerShell
PnP PowerShell is a community‑driven module that makes tenant‑level operations easier and is actively maintained for modern SharePoint.
The main cmdlet you’ll use is Get‑PnPTenantSite.
Basic syntax
Get-PnPTenantSite [-Identity] [-Detailed] [-Template] [-IncludeOneDriveSites] `
[-GroupIdDefined] [-Filter] [-DisableSharingForNonOwnersStatus]Key parameters:
- Identity – URL of a specific site collection.
- Detailed – Returns extended properties.
- Template – Filter by site template, similar to
Get-SPOSite. - IncludeOneDriveSites – Include all OneDrive for Business sites in the results.
- GroupIdDefined –
$truefor group‑connected sites. - Filter – String‑based filter, e.g.,
"Url -like 'sales'". - DisableSharingForNonOwnersStatus – Show sites where sharing for non‑owners is blocked.
Check out Get All Microsoft 365 Group Connected SharePoint Sites using PowerShell
Example 8: Get all SharePoint Online Site Collections
This PnP PowerShell command will give all the SharePoint site collections from the active sites in the SharePoint admin center.
$AdminUrl = "https://yourtenant-admin.sharepoint.com"
Connect-PnPOnline -Url $AdminUrl -Interactive
Get-PnPTenantSiteThis returns all SharePoint site collections (excluding OneDrive sites by default) with basic info like URL and template.

Example 9: Get all SharePoint Sites including OneDrive
If you need a truly complete list of all collaboration spaces including personal OneDrive sites:
Get-PnPTenantSite -IncludeOneDriveSitesUse this carefully, as OneDrive counts can be very high in large organizations.
Example 10: Get a Single SharePoint Site by URL
This example gives the specific SharePoint site Url information.
$SiteUrl = "https://yourtenant.sharepoint.com/sites/EventPlanning"
Get-PnPTenantSite -Identity $SiteUrlThis returns just that specific SharePoint site with its core properties like in the screenshot below:

Check out Upload Single or Multiple Files to SharePoint with Metadata Using PnP PowerShell
Filter tenant sites with Get‑PnPTenantSite
We can use similar filters in PnP to quickly segment our sites.
Example 11: Filter by URL
This PowerShell command filters the SharePoint site collections based on their Url.
Get-PnPTenantSite -Filter "url -like 'Project' "This lists all SharePoint sites that have “Project” in their URL, which is useful if you follow a naming convention.

Example 12: Get All SharePoint Sites including OneDrive Sites
This PowerShell command gives all the SharePoint site collections, including all OneDrive sites.
Get-PnPTenantSite -IncludeOneDriveSitesYou can see the exact output in the screenshot below:

Example 13: Only group‑connected SharePoint Sites
This command gives SharePoint sites that are connected to a Microsoft 365 group.
Get-PnPTenantSite -GroupIdDefined $trueThis returns only the SharePoint sites that are backed by Microsoft 365 groups (for example, team sites created from Teams or Outlook). Here is the exact output in the screenshot below:

Check out How to Check SharePoint Version Using PowerShell
Export Tenant SharePoint Sites to CSV with PnP PowerShell
Just like with Get-SPOSite, you’ll often want to export the PnP results to a CSV file.
Example 13: Export all SharePoint Sites to Excel
$AdminUrl = "https://yourtenant-admin.sharepoint.com"
$CsvPath = "C:\Temp\PnP-AllSites.csv"
Connect-PnPOnline -Url $AdminUrl -Interactive
Get-PnPTenantSite -Detailed |
Select Title, Url, Owner, LastContentModifiedDate, WebsCount, Template, StorageUsage |
Export-Csv -Path $CsvPath -NoTypeInformation -Encoding UTF8This script gives you a detailed report with SharePoint site counts, last activity date, and storage usage, which is perfect for governance and cleanup projects.
When to use Get‑SPOSite vs Get‑PnPTenantSite
Both cmdlets can give you a list of all SharePoint Online site collections, but they have slightly different strengths.
| Scenario | Use Get‑SPOSite | Use Get‑PnPTenantSite |
|---|---|---|
| You prefer Microsoft‑built modules | Yes | Maybe |
| You want modern, cross‑platform automation | Limited | Yes (PowerShell 7, cross‑platform) |
| You need to include OneDrive sites | IncludePersonalSite | IncludeOneDriveSites |
| You already use PnP for other scripts | Not required | Best choice |
| You need rich tenant‑wide reporting | Good | Excellent with -Detailed |
Best Practices
Here are some best practices you can follow while working with PowerShell to get SharePoint site collections.
- Always use the admin center URL for tenant‑level operations (
https://yourtenant-admin.sharepoint.com). - Prefer
-Limit AllwithGet-SPOSitewhen you truly need a complete list; otherwise, large tenants might appear incomplete. - Use
Selectto keep only the columns you actually need; this makes CSV files smaller and easier to read. - Store CSV files in a secure location, as site URLs and owners are often considered sensitive.
In this tutorial, we discussed how to get all the SharePoint site collections using PnP PowerShell. We saw a lot of examples including PnP PowerShell cmdlets.
You may also like the following tutorials:
- PowerShell SharePoint Commands And Examples
- How to Get File Modified Date using PowerShell
- Get SharePoint List Name using PowerShell
- Configure a Sensitivity Label For a SharePoint Document Library

After working for more than 18 years in Microsoft technologies like SharePoint, Microsoft 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (12 times). I have also worked in companies like HP, TCS, KPIT, etc.