Update SharePoint groups in all webs in a SiteCollection using PowerShell

Say you have a ton of subwebs in a sitecollection. Each web have unique permissions and unique groups.

You would like to update alle membergroups to have Contribute permissions, instead of Edit permissions. If you need to update all ownergroups or visitorgroups, just change the script accordingly.

You do it like this:

<h1>Get the URL of your SiteCollection</h1>
$site = Get-SPSite https://intranet.domain.com/path/site

#Go through each site
foreach ($web in $site.AllWebs)
# Get the Member group of the current site
$group = $web.Groups | Where {$_.Name -Like 'Member*'}
echo $group.Name
$ra = $group.ParentWeb.RoleAssignments.GetAssignmentByPrincipal($group)

# Define the permissionlevel you wish to remove
$rd = $group.ParentWeb.RoleDefinitions["Contribute"]

# Define the permissionlevel you wish to add
$rd = $group.ParentWeb.RoleDefinitions["Edit"]


Source: http://sharepoint.stackexchange.com/questions/70071/need-to-remove-permission-level-from-a-sharepoint-group-using-powershell

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.