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

1 Answer 1


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)

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

        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>]

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

An Example:

Set-SPUser -Identity 'domain\name' -Web http://sp2test/site -AddPermissionLevel Read
  • Thanks for the fast response. So instead of -Identity "Domain\login" could I use. -Group $Site.AdministratorsGroup
    – user13186
    Mar 19, 2013 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/… Mar 19, 2013 at 2:55
  • $listItem.RoleAssignments.Add did not work for me, I had to change it to $listItem.Web.RoleAssignments.Add
    – tsap
    Nov 11, 2015 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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