This article discusses ways to modify list permissions, such as breaking list inheritance, resetting inheritance, resetting list item permission inheritance and removing all list permissions with PowerShell.
Let’s say you create a shiny new custom list without changing any of the defaults. Later, you realize that you wanted unique permissions on the list. If you use the web interface to "Stop Inheriting Permissions", existing permissions from the parent web site will get copied to the list. Rather than deleting all the user/group permissions that you DON’T want applied to the list, it may be easier to start with minimal permissions like so:
# Add the PowerShell Snap-In Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue # Retrieve the list $web = Get-SPWeb http://web_site_url $list = $web.Lists["Your List Name"] # Break inheritance if the list has inherited permissions If (! $list.HasUniqueRoleAssignments) { $list.BreakRoleInheritance($FALSE) }
On the other hand, perhaps you have a list that has unique permissions and you want to reset inheritance. The following will reset the list and all list child items:
# Add the PowerShell Snap-In Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue # Retrieve the list $web = Get-SPWeb http://web_site_url $list = $web.Lists["Your List Name"] # Display basic list information "List Title: $list.Title" $ItemCount = $list.ItemCount "Item Count: $($ItemCount)" $CurItem = 0 # Reset permission inheritance on the list $list.ResetRoleInheritance() # Reset permission inheritance on each list item ForEach ($item in $list.items) { $CurItem++ "Working on item $($CurItem) / $($ItemCount)" $item.ResetRoleInheritance() }
Sometimes you just want to start over. Maybe your list/library has become clogged with loads of useless permissions. I'm looking at you "Limited Access" permission! The following will remove ALL list permissions:
# Add the PowerShell Snap-In Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue # Retrieve the list $web = Get-SPWeb http://web_site_url $list = $web.Lists["Your List Name"] # Display basic list information "List Title: $($list.Title)" $ItemCount = $list.ItemCount "Item Count: $($ItemCount)" $CurItem = 0 $ra = $list.RoleAssignments.Count $ra0b = $ra -1 # Remove ALL list permissions For ($i = $ra0b; $i -ge 0; $i--) { $CurItem++ "Working on Role Assignment $($CurItem) / $($ra)" $list.RoleAssignments.Remove($i) }