Steps Involved:
- Open SharePoint 2010 Management Shell by going to Start | All Programs | SharePoint | Microsoft SharePoint 2010 Products | SharePoint 2010 Management Shell (Run as Administrator).
- Run the following script.
Powershell Script:
##Add a colleague for the specified user using SharePoint 2010 web service in powershell $uri="http://serverName:10736/sites/ECT2/_vti_bin/UserProfileService.asmx?wsdl" ## $accountName is a string that contains the account name for which you need to add the colleague [String]$accountName="domainName\accountName" ## $colleagueAccountName ia a string that contains the account name of the colleague that has to be added [String] $colleagueAccountName="domainName\colleagueAccountName" ## $group is a string that contains the group to which the colleague is a member [String] $group="General" ## $privacy is used to represent the privacy level ## For more information on Privacy Enumeration please refer http://msdn.microsoft.com/en-us/library/websvcuserprofileservice.privacy.aspx $privacy="Public" ## isInWorkGroup is a bool value which indicate that the colleague should be part of a workgroup $isInWorkGroup=$true
## Web Service Reference - http://Site/_vti_bin/UserProfileService.asmx $userProfileWebServiceReference = New-WebServiceProxy -Uri $uri -UseDefaultCredential $contactData=$userProfileWebServiceReference.AddColleague($accountName,$colleagueAccountName,$group,$privacy,$isInWorkGroup) ## $contactData - Return value will be [UserProfileService Web service].ContactData Write-Host -ForegroundColor Green "New Colleague added successfully" $contactData
|
Output: