Wednesday, May 16, 2012

Powershell - Creating a SharePoint Group w/Another Group as Owner

I wanted to create a SharePoint group on a site collection with:
  • No rights to any sites, just create the group
  • A sharepoint group as the owner of the new group
  • Done using Powershell
$siteURL="http://sitecollection/"
$webName = "sitename"
$spWeb=$spSite.OpenWeb($webName)
[Microsoft.SharePoint.SPMember]$GroupOwner = $spWeb.SiteGroups["Group Name"]
$newGroup = $spWeb.SiteGroups.Add("Group Name", $GroupOwner, $null, "Description")

For reference, you could replace the $null with a user that you would like to be a part of the group

I think that's everything, I pulled everything I thought was necessary from a much larger script.

No comments:

Post a Comment