How to break permissions for a folder at the top level of sharepoint library and assign Sharepoint groups ? I dont want to break permissions for sub folders only the root folders needs to breaking permissions .

  • Your use of the word "folder" is confusing when compared to your Title where you use phrase "document library". Are you asking how you break permissions on the library and assign groups to that library using PowerShell?
    – Erik Perez
    Commented Dec 17, 2015 at 5:26

2 Answers 2


Yes this is possible and through an simple ps script. I have searched a little bit and found a similar question with a good answer.

Possible duplicate of breakroleinheritance for a folder powershell csom.

Another way to do this:

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
 $site = new-object Microsoft.SharePoint.SPSite("http://myserver/")
 $web = $site.OpenWeb()

 function GrantGroupPermission($groupName)
      [Microsoft.SharePoint.SPGroupCollection]$spgroups = $web.SiteGroups
      [Microsoft.SharePoint.SPGroup]$spgroup = $groups[$groupName]
      $sproleass=new-object Microsoft.SharePoint.SPRoleAssignment([Microsoft.SharePoint.SPPrincipal]$spgroup)
      Write-Host "Permission provided for group ", $groupName

 function GrantUserpermission($userName)
      $sproleass=new-object Microsoft.SharePoint.SPRoleAssignment([Microsoft.SharePoint.SPPrincipal]$spuser)
      Write-Host "Permission provided for user ", $userName

 $doclib=[Microsoft.SharePoint.SPDocumentLibrary]$web.Lists["Shared Documents"]

 // Here you should only process YOUR folder
 foreach($folder in $foldercoll)
      Write-Host $folder.Name


 Write-Host "Completed...."

  • I had this code implemented and was working as expected . But this code is going to loop in through all the folders and sub folders as well. Is there a way to loop in only folders at root level ?
    – Nikhil J
    Commented Dec 17, 2015 at 14:27
  • I have changed my code to get the rootfolder first and after that to loop through the subfolders.
    – BOG
    Commented Dec 17, 2015 at 17:22
  • $folder.BreakRoleInheritance($false) is executed I get an error . I tried the $RootFolder.ListItemAllFields.BreakRoleInheritance($true,$false) with no luck
    – Nikhil J
    Commented Dec 18, 2015 at 13:23

SharePoint permissions works in a top to bottom format. Meaning, if you break/alter the root level permission, then all the relevant sub folders will get impacted.

But, you can still manage the permissions or individually assign permissions to those sub folders via individual groups/people similar to the root site. But this is very tedious if you have several sub folders and folders.

I would advice to use powershell with CSOM which has better api support if not ideal solution is to develop a console application referring the dll's.

  • 1
    Agree with what you said in first part . but why can't I have powershell script to do this ? Just want to loop through folders and have permission assigned to root shld be difficult I guess .
    – Nikhil J
    Commented Dec 17, 2015 at 3:46
  • @UserSP: Please have a look at my answer below. I have edited it. I should do exactly what you are searching for. Dont forget to mark it as answer if it helps.
    – BOG
    Commented Dec 17, 2015 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.