First of all, i want to apologize for my english :) Im just a french student.

I work on SP 2013 for 3 weeks now. I'm using it with powershell. I have to write a script that will create web app, sites collection, subsite on 2 levels, and finally document libraries. I have to set permissions for several users, on each library, in powershell.

The New-SPUser and Set-SPUser do not work with a library's url.

So I found things like this Add group to Library permissions using powershell.

EDIT : I succeeded in creating the good rights for my user on a document library which is not in a subsite.

So I thought I can do the same, by using Get-SPWeb instead of Get-SPSite, but no.

So I'm still not able to set permissions on a subsite's document library =/ and by the way, i can't add users/groups to set their permissions


You have to break inheritance before you are able to change permissions for a SPWeb. Refer to this link.

|improve this answer|||||
  • Thanks for your reply. I've already done this, with $list.BreakRoleInheritance($true) – Nico Jun 24 '13 at 13:18
  • Do you mean I have to do this for subsites ?? – Nico Jun 24 '13 at 13:20
  • It depends on your requirements. In your example you broke inheritance at the list level only. If you needed to change permissions for a sub-site you would to the same for the respective SPWeb object. – Miguel Lima Jun 24 '13 at 13:23
  • Hum ok, That's clever :D I think the problem comes from the fact that I have lists in subsites... And i want so set permissions for each lists. I'll test it asap, and post if I find something interesting. Thank you @Miguel Lima – Nico Jun 24 '13 at 13:29

I think i've found something interesting. I'll test it and come back if it's the solution : http://urlmin.com/qye

$web = Get-SPWeb http://sp-2010
$account = $web.EnsureUser("SHAREPOINT\mray")
$role = $web.RoleDefinitions["Contribute"]

$list = $web.Lists["Shared Documents"]


$assignment = New-Object Microsoft.SharePoint.SPRoleAssignment($account)

|improve this answer|||||

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.