Associate Custom Groups Using PowerShell


Niklas Goude
-Expert in Residence

You can associate Custom Groups in SharePoint 2010 as Visitor Group, Member Group or Owner Group. This is a scenario that you might encounter if you’re creating Web sites using code. To associate custom-created groups, you can use the spWeb property bag directly as shown below. First, you can retrieve a specific Web site:

PS > $spWeb = Get-SPWeb http://SP01.powershell.nu

Next, get the group that you want to associate:

PS > $group = $spWeb.SiteGroups[My New Group] 

Try this if you want to associate the Group as a Owner Group:

PS > $spWeb.Properties["vti_associateownergroup"] = $group.Id

If you want to associate the Group as a Member Group:

PS > $spWeb.Properties["vti_associatemembergroup"] = $group.ID

If you want to associate the Group as a Visitor Group:

PS > $spWeb.Properties["vti_associatevisitorgroup"] = $group.ID

When you’re done, you can use the Update() method to commit the changes:

PS > $spWeb.Properties.Update()

PS > $spWeb.Dispose()

Twitter This Tip! ReTweet this Tip!


Posted Sep 05 2011, 06:00 AM by sos

Comments

The Mit's Blog wrote SharePoint 2010 : Création des groupes de sécurité à posteriori et gestion de l’héritage des permissions
on 11-01-2011 8:52 AM

C’est un constat : on créé souvent des sites SharePoint plus rapidement qu’on le pense. En pratique,

Idera SharePoint Reviews SMBology, Inc. Rackspace Hosting Sponsored by Idera and SharePoint Reviews and SMBology and EPCGroup.net
Copyright 2011 SecretsOfSharePoint.com. All rights reserved.