Wednesday, 11 May 2016

Delete all sites from a site collection

$url = "http://yourweb.com"
$subsites = ((Get-SPWeb $url).Site).allwebs | ?{$_.url -like $url +"/*"}

foreach($subsite in $subsites) { Remove-SPWeb $subsite.url }


Here you go, full script of deleting all subsites / webs under a site collection, you can also add your subsite to delete the childs of that subsite only.

No comments:

Post a Comment