How to Create Default Groups in SharePoint Site?

The default SharePoint groups are created automatically when you create a site collection through SharePoint Web UI. But, when you create SharePoint sites programmatically or with PowerShell (E.g. New-SPSite or New-SPWeb), The default site groups (such as: Visitors, Members, Owners) are not created automatically!

Default groups creation from UI: You can get the default group page from SharePoint UI by navigating to: . Enter group details and hit "Save".
How to Create Default Site Groups in SharePoint
How to create default SharePoint groups:
You have to call the method: SPWeb.CreateDefaultAssociatedGroups explicitly. to create default user groups in SharePoint.

Create Default User Groups programmatically using PowerShell:
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

#Variables for Site collection
$SiteURL =""
$Site = Get-SPSite $SiteURL

#get the Root Web object
$RootWeb = $Site.RootWeb

$GroupOwner = "i:0#.w|global\salaudeen" 
$RootWeb.CreateDefaultAssociatedGroups($GroupOwner, "", $RootWeb.title)

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.