Add user to the group 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 user to the group using SharePoint 2010 web service in powershell
$uri="http://serverName:10736/sites/ECT/_vti_bin/UserGroup.asmx?wsdl"
## $groupName is a string that contains group name in which the user has to be added
[
String]$groupName ="NewGroup";
## $userName is a string that contains user name
[
String]$userName="Karthic"
## $userLoginName is a string that contains (domainName\userName)that has to be added to the specified group
[
String]$userLoginName="domainName\userName"
## $userEmail is a string that contains the user email address
[
String]$userEmail="[email protected]"
## $userNotes is a string that contains notes for the user
[
String]$userNotes="My notes"
## Web Service Reference - http://Site/_vti_bin/UserGroup.asmx
$usergroupWebServiceReference = New-WebServiceProxy -Uri $uri -UseDefaultCredential
$usergroupWebServiceReference.AddUserToGroup($groupName,$userName,$userLoginName,$userEmail,$userNotes)


Summary:


Using the above script you will be able to add an user to the specified group.


Ebook Download
View all
Learn
View all