Add a new group to the site collection using SharePoint 2010 web service in powershell

Steps Involved:

  1. Open SharePoint 2010 Management Shell by going to Start | All Programs | SharePoint | Microsoft SharePoint 2010 Products | SharePoint 2010 Management Shell (Run as Administrator).
  2. Run the following script.

Powershell Script:

 
## Add a new group to the site collection using SharePoint 2010 web service in powershell
$uri="http://serverName:10736/sites/ECT/_vti_bin/UserGroup.asmx?wsdl"
## $groupName is a string that contains new group name
[
String]$groupName ="NewGroup";
## $ownerIdentifier is a string that contains group owner (domainName\userName)
[
String]$ownerIdentifier="domainName\userName"
## $ownerType is a string that contains the user type, which can be either user or group
[
String]$ownerType="user"
## $defaultUserLoginName is a string that contains the default user(domainName\userName)that will be added to the group
[
String]$defaultUserLoginName="domainName\userName"
## $description is a string that contains description for the new group
[
String]$description="New group added to the site using SharePoint 2010 web service in powershell"
## Web Service Reference - http://Site/_vti_bin/UserGroup.asmx
$usergroupWebServiceReference = New-WebServiceProxy -Uri $uri -UseDefaultCredential
$usergroupWebServiceReference.AddGroup($groupName,$ownerIdentifier,$ownerType,$defaultUserLoginName,$description)


Using the above script you will be able to add a new group to the site.