/flags/sharepoint-online/get-sposite-limit-all
Get-SPOSite -Limit All: list every site, not just the first 200
- tool
- SharePoint Online PowerShell
- command
- Get-SPOSite
- flag
- -Limit
- default
- 200
Get-SPOSite -Limit All returns every site collection in the tenant. Without it, the cmdlet stops after 200: the reference says -Limit "Specifies the maximum number of site collections to return. It can be any number. To retrieve all site collections, use ALL. The default value is 200." Reports and scripts that loop over sites without -Limit All silently skip everything after the 200th site.
Connect-SPOService -Url https://contoso-admin.sharepoint.com
Get-SPOSite -Limit All | Measure-Object
Get-SPOSite -Limit All -Filter "Owner -eq 'anna@contoso.com'" | Select-Object Url, Owner
Get-SPOSite -Limit All -Template GROUP#0 # Microsoft 365 group sitesThe parameter in the module
-Limit is a string, so All, ALL and a number are passed to the service as text; PowerShell does not validate the value. Checked offline in Windows PowerShell 5.1 with the SharePoint Online Management Shell module 16.0.27709.12000:
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
$c = Get-Command Get-SPOSite
"Limit type: " + $c.Parameters['Limit'].ParameterType.Name
"Limit in parameter sets: " + (($c.Parameters['Limit'].ParameterSets.Keys | Sort-Object) -join ', ')
try { Get-SPOSite -Limit All -ErrorAction Stop } catch { $_.Exception.Message }Output
Limit type: String Limit in parameter sets: ParamSet1, ParamSet2 No connection available. Use Connect-SPOService before running this CmdLet.
The last line shows the typical first error: without Connect-SPOService the cmdlet fails with No connection available.
Combinations
| Command | Returns |
|---|---|
| Get-SPOSite | up to 200 sites, no OneDrive |
| Get-SPOSite -Limit All | all sites, no OneDrive |
| Get-SPOSite -Limit All -IncludePersonalSite $true | all sites including OneDrive |
| Get-SPOSite -Limit All -Filter "Owner -eq 'anna@contoso.com'" | server-side filter (Owner, Template, LockState, Url, IsAuthoritative) |
| Get-SPOSite -Limit All -Template STS#3 | only sites of one template |
| Get-SPOSite -Identity URL -Detailed | one site with all properties |
Pitfalls
- Incomplete properties. As the reference notes, "If this parameter is provided, then some site collection properties will not be populated and may contain a default value." Do not build compliance reports on those columns without checking a site with
-Identity. - Filter syntax. Valid operators are
-eq,-ne,-like,-notlike; operators are case-sensitive and-oris not supported. - Admin URL. Connect to the
-adminURL, not the root site, or you get Current site is not a tenant administration site. - Large tenants. Tens of thousands of sites take a while; filter on the server instead of piping everything into
Where-Object. - Storage. For size and quota per site, see Get-SPOSite storage usage.
FAQ
Why does Get-SPOSite return exactly 200 sites?
200 is the documented default of -Limit. Add -Limit All to return every site collection, or a number to set another maximum.
Why are some properties empty with -Limit All?
The reference warns that when -Limit is provided, some site collection properties are not populated and may contain a default value. Query a single site with Get-SPOSite -Identity URL -Detailed for complete values.
Does -Limit All include OneDrive sites?
No. OneDrive (personal) sites are excluded unless you add -IncludePersonalSite $true.