Forum Discussion

An_admin_123's avatar
An_admin_123
Copper Contributor
May 17, 2023

I'd like to find the total number of sites in SharePoint online

All my SPO sites start company.sharepoint.com/, I'm trying to find out the total number of sites and subsites below that.  So far I can't find anything which can show me a total number.  Can anyone help please?

3 Replies

  • An_admin_123's avatar
    An_admin_123
    Copper Contributor

    An_admin_123

     

    Connect-SPOService -Url https://yourtenant-admin.sharepoint.com
    $sites = Get-SPOSite -Limit All
    $totalSites = $sites.Count
    Write-Host "Total number of sites in the tenant: $totalSites"
    Disconnect-SPOService

     

    That gets me "12" which is definitely wrong.  It's at least 100.  It doesn't seem to be counting the subsites of subsites.

  • BobLatency's avatar
    BobLatency
    Copper Contributor
    You probably found a solution by now, but in case anyone else stumbles on this thread and needs a quick answer this works, just tested live. Assume you have the latest SPO management shell installed.

    Connect-SPOService -Url https://yourtenant-admin.sharepoint.com
    $sites = Get-SPOSite -Limit All
    $totalSites = $sites.Count
    Write-Host "Total number of sites in the tenant: $totalSites"
    Disconnect-SPOService

Resources