{"id":1493,"date":"2013-11-27T06:01:22","date_gmt":"2013-11-27T06:01:22","guid":{"rendered":"https:\/\/poiseddevelopers.com\/reality-tech\/?p=1493"},"modified":"2024-04-12T04:56:39","modified_gmt":"2024-04-12T04:56:39","slug":"how-to-delete-all-sharepoint-webs-in-a-site-collection-except-the-root-web","status":"publish","type":"post","link":"https:\/\/poiseddevelopers.com\/reality-tech\/how-to-delete-all-sharepoint-webs-in-a-site-collection-except-the-root-web\/","title":{"rendered":"How to delete all SharePoint webs in a Site Collection, except the root web"},"content":{"rendered":"<p>Pretty useful and simple to delete all webs in a site collection except the root web. This worked for me, because there isn\u2019t 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.<\/p>\n<pre lang=\"php\">\r\nget-spsite ht tp:\/\/SharePoint SiteURL | get-spweb -Limit all  | Where-Object {$_.isrootweb -ne $true} | % {$_.delete()}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Pretty useful and simple to delete all webs in a site collection except the root web. This worked for me, because there isn\u2019t 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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1495,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[26],"tags":[],"class_list":["post-1493","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"_links":{"self":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1493","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/comments?post=1493"}],"version-history":[{"count":3,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1493\/revisions"}],"predecessor-version":[{"id":1497,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1493\/revisions\/1497"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media\/1495"}],"wp:attachment":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media?parent=1493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/categories?post=1493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/tags?post=1493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}