SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

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

share|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
up vote 0 down vote accepted

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

$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)

share|improve this answer
It works perfectly ! Will accept it as an answer but tomorrow. Can't do it today ~.~ – Nico Jun 25 '13 at 7:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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