Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am looking to set a site admins as the only people who can use a certain page via powershell, so far I have only been able to check permissions not set any

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

EDIT: Misread the question you can try this

$site = get-spsite("http://MySPSite")
$web = $site.RootWeb
$list = $web.Lists["MyList"]
$listitem = $list.Items[0] 
$user = $web.AllUsers["Domain\User"]
$role = $web.RoleDefinitions["Full Control"]
$roleassignment = New-Object Microsoft.SharePoint.SPRoleAssignment($user)
$roleassignment.RoleDefinitionBindings.Add($role)
$listitem.RoleAssignments.Add($roleassignment)
$listitem.Update()

I'm not sure if this will break inheritance automatically, you may have to explicitly do that for this to work.

Use set-spuser for site permissions

SYNTAX
        Set-SPUser [-Identity] <SPUserPipeBind> [-AddPermissionLevel <String[]>] [-AssignmentCollection 
        <SPAssignmentCollection>] [-ClearPermissions <SwitchParameter>] [-Confirm [<SwitchParameter>]] 
        [-DisplayName <String>] [-Email <String>] [-Group <SPGroupPipeBind>] [-IsSiteCollectionAdmin 
        <SwitchParameter>] [-PassThru <SwitchParameter>] [-RemovePermissionLevel <String[]>] [-SyncFromAD 
        <SwitchParameter>] [-Web <SPWebPipeBind>] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]


    DESCRIPTION
        The Set-SPUser cmdlet configures properties of an existing user.

An Example:

Set-SPUser -Identity 'domain\name' -Web http://sp2test/site -AddPermissionLevel Read
share|improve this answer
    
Thanks for the fast response. So instead of -Identity "Domain\login" could I use. -Group $Site.AdministratorsGroup –  user13186 Mar 19 '13 at 2:50
    
Groups take a bit more work. Take a look here and see if this doesn't work better for you sharepoint.stackexchange.com/questions/58293/… –  Jesus Shelby Mar 19 '13 at 2:55
add comment

Your Answer

 
discard

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.