Thursday, September 26, 2013

Removing customized permissions for SharePoint list items and documents or Re-inheritance from Parent using Powershell

Background and Problem
Recently we had to reset the permission of a large number of files so that they would inherit permissions from the library instead of having their own customized permissions. We had gotten into a pickle after copying over 50 thousand files over to a new location only to realize later that the client did not need the file-level permission from the old location.

The Solution
Of course we could have redone the copy, which was originally with a third party tool, specifying not to include the permissions. We did that for the files we copied later. For the first set of file, we simply wrote a simple one-liner PowerShell to do the re-inheritance as follows.

(get-spweb "http://example.org/sites/somesite").Lists["Collaboration"].Items | %{ $_.ResetRoleInheritance() }

I was surprised by how fast this runs. It only took a few seconds. It went ahead and reset all the items and folders in the library.

No comments:

Post a Comment