{"id":66,"date":"2017-12-01T09:34:20","date_gmt":"2017-12-01T09:34:20","guid":{"rendered":"http:\/\/4us2use.at\/?p=66"},"modified":"2018-03-09T12:16:04","modified_gmt":"2018-03-09T12:16:04","slug":"removing-all-broken-inhertiance-and-permissions-complete-site-collection","status":"publish","type":"post","link":"http:\/\/4us2use.at\/?p=66","title":{"rendered":"Removing all broken inhertiance and permissions complete site collection"},"content":{"rendered":"<p>Problem Description:<\/p>\n<p>if you need to remove all permissions and broken inheritances from a complete site collection, you may run this script\u200b<\/p>\n<p>Resolution:<\/p>\n<p>Add-PSSnapin Microsoft.SharePoint.PowerShell<br \/>\n$site = Get-SPSite https:\/\/URL<br \/>\n$webs = $site.AllWebs<br \/>\nforeach ($web in $webs){<br \/>\nif ( ($web.HasUniqueRoleAssignments) -and ($web.IsRootWeb -eq $false ) ){<br \/>\n$web.ResetRoleInheritance()}<br \/>\nWrite-Host &#8220;Removed broken inheritance on web: &#8221; $web.Url -ForegroundColor Red<br \/>\n}<\/p>\n<p>$lists=$web.Lists<br \/>\nforeach ($list in $lists){<br \/>\nif (($list -ne $null) -and ($list.HasUniqueRoleAssignments)){<br \/>\n$list.ResetRoleInheritance()<br \/>\nWrite-Host &#8220;Removed broken inheritance on list: &#8221; $list.Title -ForegroundColor Blue<br \/>\nClear-Variable list<br \/>\n}<\/p>\n<p>Write-Host &#8220;Entering list to remove single item permission: &#8221; $list.Title<br \/>\n$items = $list.items | Where {$_.HasUniqueRoleAssignments}<br \/>\nforeach ($item in $items){<br \/>\n$item.ResetRoleInheritance()<br \/>\nWrite-Host &#8220;Removed broken inheritance on item: &#8221; $item.Name -ForegroundColor Green<br \/>\nClear-Variable item<br \/>\n}}<br \/>\n$web.Dispose()<br \/>\n}<\/p>\n<p>Remove all permissions<br \/>\n$groups = $web.SiteGroups<br \/>\nfor ($i=0;$i -le $groups.Count;$i++){<br \/>\n$web.SiteGroups.Remove($groups[$i])<br \/>\n}<br \/>\n$users = Get-SPUser -Web $web -Limit all<br \/>\nfor ($i=0;$i -le $users.Count;$i++){<br \/>\nRemove-SPUser -Web $web -Identity $users[$i] -Confirm:$false<br \/>\n}<\/p>\n<span id=\"post-ratings-66\" class=\"post-ratings\" data-nonce=\"e9df1ca0d2\"><img id=\"rating_66_1\" src=\"http:\/\/4us2use.at\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_off.gif\" alt=\"1 Star\" title=\"1 Star\" onmouseover=\"current_rating(66, 1, '1 Star');\" onmouseout=\"ratings_off(0, 0, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/><img id=\"rating_66_2\" src=\"http:\/\/4us2use.at\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_off.gif\" alt=\"2 Stars\" title=\"2 Stars\" onmouseover=\"current_rating(66, 2, '2 Stars');\" onmouseout=\"ratings_off(0, 0, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/><img id=\"rating_66_3\" src=\"http:\/\/4us2use.at\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_off.gif\" alt=\"3 Stars\" title=\"3 Stars\" onmouseover=\"current_rating(66, 3, '3 Stars');\" onmouseout=\"ratings_off(0, 0, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/><img id=\"rating_66_4\" src=\"http:\/\/4us2use.at\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_off.gif\" alt=\"4 Stars\" title=\"4 Stars\" onmouseover=\"current_rating(66, 4, '4 Stars');\" onmouseout=\"ratings_off(0, 0, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/><img id=\"rating_66_5\" src=\"http:\/\/4us2use.at\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_off.gif\" alt=\"5 Stars\" title=\"5 Stars\" onmouseover=\"current_rating(66, 5, '5 Stars');\" onmouseout=\"ratings_off(0, 0, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/> (No Ratings Yet)<br \/><span class=\"post-ratings-text\" id=\"ratings_66_text\"><\/span><\/span><span id=\"post-ratings-66-loading\" class=\"post-ratings-loading\"><img src=\"http:\/\/4us2use.at\/wp-content\/plugins\/wp-postratings\/images\/loading.gif\" width=\"16\" height=\"16\" class=\"post-ratings-image\" \/>Loading...<\/span>\n","protected":false},"excerpt":{"rendered":"<p>Problem Description: if you need to remove all permissions and broken inheritances from a complete site collection, you may run this script\u200b Resolution: Add-PSSnapin Microsoft.SharePoint.PowerShell $site = Get-SPSite https:\/\/URL $webs = $site.AllWebs foreach ($web in $webs){ if ( ($web.HasUniqueRoleAssignments) -and ($web.IsRootWeb -eq $false ) ){ $web.ResetRoleInheritance()} Write-Host &#8220;Removed broken inheritance on web: &#8221; $web.Url -ForegroundColor &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/4us2use.at\/?p=66\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Removing all broken inhertiance and permissions complete site collection&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[],"_links":{"self":[{"href":"http:\/\/4us2use.at\/index.php?rest_route=\/wp\/v2\/posts\/66"}],"collection":[{"href":"http:\/\/4us2use.at\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4us2use.at\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4us2use.at\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4us2use.at\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=66"}],"version-history":[{"count":4,"href":"http:\/\/4us2use.at\/index.php?rest_route=\/wp\/v2\/posts\/66\/revisions"}],"predecessor-version":[{"id":152,"href":"http:\/\/4us2use.at\/index.php?rest_route=\/wp\/v2\/posts\/66\/revisions\/152"}],"wp:attachment":[{"href":"http:\/\/4us2use.at\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=66"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4us2use.at\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=66"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4us2use.at\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=66"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}