SharePoint 2010/2013: Modifying the Permission Level of a Group Using Powershell

Scenerio: 

well I had a SharePoint group with around 50 users given Contribute permission. Then it was required to raise its permission to “Full Control”. Here is how I did that using Powershell script:

Adding a Permission Level

$web = Get-SPWeb "http://SiteCollection"
$group = $web.SiteGroups["GroupName"]
roleAssignment= New-Object Microsoft.SharePoint.SPRoleAssignment($group)
$role = $web.RoleDefinitions["PermissionLevel"]
$roleAssignment.RoleDefinitionBindings.Add($role);
$web.RoleAssignments.Add($roleAssignment)
$web.Dispose()

Removing a Permission Level

$web = get-spweb "http://SiteCollection"
$group = $web.SiteGroups["GroupName"]
$roleAssignment = $group.ParentWeb.RoleAssignments.GetAssignmentByPrincipal($group)
$role = $group.ParentWeb.RoleDefinitions["PermissionLevel"]
$roleAssignment.RoleDefinitionBindings.Remove($role)
$roleAssignment.Update()
$group.Update()
$web.Dispose()

References

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *