I'm trying to modify the permission of a library through Power Shell.

What I want to do is:

  1. I have a library with one folder for each user, but now, all this folders inherite the permissions from the library.

  2. All my Sharepoint users are Active Directory users.

  3. Each user has a folder with his Full Name as folder name. I want to break inherite in all folders and give read permission to the appropiate user (folder name = ad user name)

Have I explained it right?

  • if full name is folder name how are you managing it is unique?
    – Unnie
    Jun 6 '14 at 10:41
  • We don't managed this at the moment. Full name is name plus two surnames (we are in Spain), so it's really dificult to get a match. Example of folder name: "Pedro Antonio Alonso Cayuela". The folders are created manually (we don't hire people everyday) for now, so if there is a match it will be renamed and it will get its permisions manually assigned Jun 6 '14 at 10:59

You can try with below script, here for group you can user your user:

function GrantUserpermission($userName)
if ($userName -ne $null)

  $sproleass=new-object Microsoft.SharePoint.SPRoleAssignment([Microsoft.SharePoint.SPPrincipal]$spuser)
  Write-Host "Permission provided for user ", $userName
 Write-Host "User ""$userName"" was not found in this web!"


Check this below link for whole script: http://sharepoint2010tutor.blogspot.in/2011/08/grant-folder-permissionsharepoint-using.html

  • Thank you very much, I only need how to clear all the folder permisions before assign new ones. Jun 11 '14 at 10:48
  • $folder.BreakRoleInheritance("true") this will clear all permissions.
    – Aanchal
    Jun 11 '14 at 10:59
  • Not really, it only break inheritance, but after I've to clean the permission Jun 12 '14 at 7:16
  • I've realized that it cleans the permissions if I use BreakRoleInheritance(0) Jun 12 '14 at 8:23
  • Yes. To remove permissions use $folder.RoleAssignments.Remove($role).
    – Aanchal
    Jun 12 '14 at 8:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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