7
votes

I want to give a Domain User SharePoint permissions on a Site. The peoplepicker in SharePoint found the user and i can add the user in the Browser to the Site. But when I use PowerShell, the User is not in the permission list on the SharePoint GUI.

PS: New-SPUser -UserAlias "test\TestUser2" -PermissionLevel Contribute -web http://test.sharepoint.de/site/page

PS:
UserLogin            DisplayName         
---------            -----------         
TEST\testuser2       TestUser2  

also not working:

Get-SPWeb "http://test.sharepoint.de/site/page" | New-SPUser –UserAlias "test\TestUser2" -PermissionLevel Contribute
3
I don't think your allowed to give permission to a user on a page, and when you get the SPWeb object on the page you'll won't get the context right, to do this you'll probably need to get to the page object and break permissions inheritance, and only then You'll be able to give permissions to the user.Gabriel Guimarães

3 Answers

3
votes

It should be this: Set-SPUser -Identity 'domain\name' -Web http://sp2test/site -AddPermissionLevel Read

1
votes

What happens if you drop the page from your command?

New-SPUser -UserAlias "test\TestUser2" -PermissionLevel Contribute -web http://test.sharepoint.de/site

Also, after you add them through the GUI, does your command work to add them to additional sites? Also, dumb question maybe, but are you running PS as a user who has access to add people to the site?

0
votes

Try adding Add-PSSnapin "Microsoft.SharePoint.PowerShell" It worked for me

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
Set-SPUser -Identity 'domain\name' -Web http://sp2test/site -AddPermissionLevel Read