Monday, June 4, 2012

Creating default associated groups

While creating a new site through the UI (Site Actions->New Site) my browser crashed. This caused the default associated groups to not get created among other things. As a result, I had to do this manually.

Looking back at a previous post, Creating predefined groups in site collection created by Powershell, I ran the following Powershell:

$web.CreateDefaultAssociatedGroups($web.Site.Owner.UserLogin, $web.Site.SecondaryContact.UserLogin, $web.Title)


I went back into Site Permissions and still didn't see my groups. Reading the SPWeb.CreateDefaultAssociatedGroups Method document's Remarks, it mentions that the AssociatedVisitorGroup and the AssociatedOwnerGroup have to be null before invoking this method. Mine were set to point to the equivalent Home groups. So I ran the following:
$web.AssociatedOwnerGroup = $null
$web.AssociatedMemberGroup = $null
$web.AssociatedVisitorGroup = $null
$web.CreateDefaultAssociatedGroups($web.Site.Owner.UserLogin, $web.Site.SecondaryContact.UserLogin, $web.Title)

and all is fine.

No comments:

Post a Comment