Monday, July 4, 2016

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 "Edit User Permissions" ribbon button sharepoint powershell change group permissions
  • Select or deselect any relevant permission levels required
    sharepoint powershell add remove group permissions
  • 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 "Edit" permission level and add "Contribute" to Members group of the SharePoint site.
#assign permission to sharepoint group powershell
Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue

#Configuration parameters
$GroupName="Crescent Intranet Members"

#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))
    Write-host "$($PermissionToAdd) Permission Added to the Group!"

#sharepoint powershell remove group permissions
if ($RoleAssignment.RoleDefinitionBindings.Contains($RemovePermissionRole))
    Write-host "$($PermissionToRemove) permission removed from the Group!"

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...