How to delete all SharePoint webs in a Site Collection, except the root web How to delete all SharePoint webs in a Site Collection, except the root web
Joel Plaut

Joel Plaut

November 27, 2013

All Post
How-to-delete
Share:

Pretty useful and simple to delete all webs in a site collection except the root web. This worked for me, because there isn’t nesting. Even with nesting and the pipeline returning SPWebs in suboptimal sequence, running this a few times will wipe at a minimum the leaf nodes whittling you down to your clean root web.

get-spsite ht tp://SharePoint SiteURL | get-spweb -Limit all  | Where-Object {$_.isrootweb -ne $true} | % {$_.delete()}

One thought on “How to delete all SharePoint webs in a Site Collection, except the root web

Leave a Reply

Your email address will not be published. Required fields are marked *

Want to talk?

Drop us a line. We are here to answer your questions 24*7.