I was cleaning up my demo site collection, and I needed to remove all subwebs… Here’s a quick one-liner of PowerShell to do exactly that.
Get-SPSite <SiteUrl> | Get-SPWeb -Limit All | ForEach-Object {Remove-SPWeb -Identity $_ -Confirm:$false}
</ShortestPostEver>
This is a good starting point, but wouldn’t it remove not just the sub-webs but the root web as well?
Hey Grant,
This will not actually remove the rootweb, it will actually give you a warning/error. For a situation where you want to quickly cleanup all of the subwebs leaving the rootweb intact, it works great!
Ryan