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

Please help me about adding new AD users, AD groups with Permission to sharepoint site. I can do it for lists and document libararys but adding to site seems to be different. This is what i do for lists:

Function Rights ($user, $ShortListName, $permission){

$userName = $spweb.EnsureUser($User)
$spFolder = $spweb.lists[$ShortListName]
        $spfolder.BreakRoleInheritance($false, $false)
        Write-Host "Permission provided for group ", $userName
      Write-Host "group ""$userName"" was not found in this web!"

If i simply change the spfolder spweb, it won't work

share|improve this question
up vote 2 down vote accepted

If you want to add permission to the SPWeb, try this:

$account = $web.EnsureUser($userName)
$assignment = New-Object Microsoft.SharePoint.SPRoleAssignment($account)
$role = $web.RoleDefinitions[$permission]
share|improve this answer

It's not clear to me what you are asking for. The title of your question is regarding adding an "AD user to SharePoint site" but your script is setting specific permissions on a folder and granting a user/group those permissions. Are you just trying to add a user or AD group to a SharePoint group like the owners/members/visitors groups? If that is the case, use this:

Set-SPUser -Identity 'domain\UserName' -Web '' -Group 'Site Members'

share|improve this answer
No. I wanted to add AD users and AD groups with permission to sp site. My code is for adding to lists. – Lokids Aug 27 '13 at 14:28

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.