How to get number of subsites in a site collection using Powershell?
['https://sharepoint.stackexchange.com/questions/140021', 'https://sharepoint.stackexchange.com', 'https://sharepoint.stackexchange.com/users/41443/']
or simply:

```
$site = Get-SPSite http://YourSharePointSite
$site.AllWebs.Count

```
```
if ($ver.Version.Major -gt 1) {$host.Runspace.ThreadOptions = "ReuseThread"} 
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) 
{
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

$sites = Get-SPSite <SiteCollectionUrl>   
$noOfWebs = 0

foreach ($web in $sites.AllWebs)
{
    $noOfWebs++
}

If ($sites -ne $null)
{
    $sites.Dispose();
}

If ($web -ne $null)
{
    $web.Dispose();
}

Write-Host "Total No of Subsites: " $noOfWebs

```