Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
4.7k views
in SharePoint Server by 40 47 56

In SharePoint 2019, I face this error Sites that have subsites or certain apps can't be deleted SharePoint 2019 but I need to know How many subsites per site collection and list all susbites using Power Shell before deleting them? How can I do that?


1 Answer

1 like 0 dislike
by 163 204 403
selected by
 
Best answer

Get All SubSites Per Site Collection Using PowerShell in SharePoint Server 2019

You can get all subsites that have been created under a specific site collection by doing the following:

  1. Open SharePoint 2019 Management Shell.
  2. Run the below cmdlet to list all subsites.

     Get-SPsite -Identity "Site Collection URL" | get-spweb -Limit all
    

    List all subsites per site collection sharepoint 2019 powershell

How many Subsites Per Site Collection in SharePoint 2019 using PowerShell?

To get the count of all subsites that have been created under a specific site collection, you have to do the following:

  1. Open SharePoint 2019 Management Shell.
  2. Run the below cmdlet to count all subsites for a site collection.

     $SubSiteCount = (Get-SPsite -Identity "Site Collection URL" | get-spweb -Limit all).count
      Write-Host "the number of subsites per site collection is" $SubSiteCount -ForegroundColor green
    

    count all subsites per site collection sharepoint 2019 powershell

See Also: Get All Site Collections and SubSites Per Farm

by 40 47 56
0 0
the links is awesome and thank you so much for your usual help
If you don’t ask, the answer is always NO!
...