Add-Remove Permissions to SharePoint Group or User with PowerShell
Updating the permission level of a SharePoint group or user is fairly straightforward. To add or remove permissions levels of the SharePoint group, navigate to:
- Site Settings >> Site permissions
- Select the person or group you want to change >> Click on the “Edit User Permissions” ribbon button
- Select or deselect any relevant permission levels required
- Click “OK” to save changes.
PowerShell script to update Permissions of a SharePoint group or User:
Here is my PowerShell script to change permissions of a SharePoint group: Say, We want to remove the “Edit” permission level and add “Contribute” to the Members group of the SharePoint site.
#assign permission to sharepoint group powershell
Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue
#Configuration parameters
$SiteURL="https://intranet.crescent.com"
$GroupName="Crescent Intranet Members"
$PermissionToAdd="Contribute"
$PermissionToRemove="Edit"
#Get the Web & Group objects
$Web = Get-SPWeb $SiteURL
$Group = $web.SiteGroups[$GroupName]
$RoleAssignment = $Web.RoleAssignments.GetAssignmentByPrincipal($Group)
#For User, Use:
#$User = $web.EnsureUser("Crescent\Salaudeen")
#$RoleAssignment = $Web.RoleAssignments.GetAssignmentByPrincipal($User)
#Get the permission Levels to Add - Remove
$AddPermissionRole = $web.RoleDefinitions[$PermissionToAdd]
$RemovePermissionRole = $web.RoleDefinitions[$PermissionToRemove]
#Add Permission level to the group
if (!$RoleAssignment.RoleDefinitionBindings.Contains($AddPermissionRole))
{
$RoleAssignment.RoleDefinitionBindings.Add($AddPermissionRole)
Write-host "$($PermissionToAdd) Permission Added to the Group!"
}
#sharepoint powershell remove group permissions
if ($RoleAssignment.RoleDefinitionBindings.Contains($RemovePermissionRole))
{
$RoleAssignment.RoleDefinitionBindings.Remove($RemovePermissionRole)
Write-host "$($PermissionToRemove) permission removed from the Group!"
}
$RoleAssignment.Update()
Hi
i need managed a permission for a subsut groub user if u have any idea
Thanks