Home > Sharepoint > Adding A Custom Group to Sharepoint

Adding A Custom Group to Sharepoint

SharePoint has a couple of default groups but say we want to create our own group. The values that we need to assign are:

String name
SPMember owner
SPUser defaultUser
String description

Name and description are strings. SPMemeber Owner and SPMember defaultUser are a little tricky.. You have to retrieve these from existing Users in SharePoint. In this example we will add the Admin account to the group.


[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

PS > $SPSite = New-Object Microsoft.SharePoint.SPSite(http://wss); $OpenWeb = $SPSite.OpenWeb(); $OpenWeb.SiteGroups.Add("The New Group", $OpenWeb.SiteUsers["BPA\sharepoint"], $OpenWeb.SiteUsers["BPA\sharepoint"],"Description of The New Group"); $OpenWeb.Update(); $OpenWeb.Dispose(); $SPSite.Dispose()

If you look in Sharepoint through Internet Explorer, the group will only be visible if you navigate to People and Groups: All Groups as shown in the screenshot below.

sharepoint-03

 

To add the group to the QuickLaunch bar, we have to add our New Group to the Associated Groups.

 


PS > $SPSite = New-Object Microsoft.SharePoint.SPSite(http://wss); $OpenWeb = $SPSite.OpenWeb(); $OpenWeb.AssociatedGroups.Add($OpenWeb.SiteGroups["The New Group"]); $OpenWeb.Update(); $OpenWeb.Dispose(); $SPSite.Dispose()

Now the group will be visible in the QuickLaunch Bar.

sharepoint-04

Rating 3.00 out of 5
[?]
Categories: Sharepoint Tags:
  1. November 17th, 2009 at 22:34 | #1

    (second try,proxy blocked first)
    I like your example and I have used some of your scripts as baselines for our needs, thanks for that.
    I am looking at this as well, but for us, we have in the past reset the Group Owner for each of the Owner, Member, Visitor groups to be the Owner group. We need, as you have mentioned, to use current members of the SP site for the initial creation but we would like to find a way to change the Owner’s Group Owner, the others are easy as they accept the Owners Group Owner if it is created first.
    I hope this isn’t too convoluted..

  1. No trackbacks yet.

Spam Protection by WP-SpamFree