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:
CreateMultipleTags.ps1
#----------------Get the xml file---------------------------------------------------------------
[xml]$xmlData=Get-Content "D:\Vijai\CreateMultipleTags.xml"
#----------------Create Multiple Tags function----------------------------------------------------
Function CreateMultipleTags()
{
##Add multiple tags with the specified keyword to the specified url using SharePoint 2010 web service in powershell
$uri="http://serverName:10736/sites/ECT/_vti_bin/SocialDataService.asmx?wsdl"
## Get the credential for which the new tag has to be added for the specified url $url
$credential=Get-Credential
Write-Host -ForegroundColor Magenta "Creating new tags........."
foreach($newTag in $xmlData.CreateTags.Tag)
{
## $url is a string that contains the URL for which the comment has to be added by the specified user
$url=$newTag.Url
## $keyword is a string that contains the contents of the social tag
$keyword=$newTag.Keyword
## $isHighPriority -true to indicate the social tag is private; otherwise, false. If this value is null, this method assumes false for this parameter.
if($newTag.IsPrivate -eq "True")
{
$isPrivate=$true
}
else
{
$isPrivate=$false
}
## $title is a string that contains the title of the social tag
$title=$newTag.Title
## Web Service Reference - http://Site/_vti_bin/SocialDataService.asmx
$socialDataServiceWebServiceReference = New-WebServiceProxy -Uri $uri -Credential $credential
$tag=$socialDataServiceWebServiceReference.AddTagByKeyword($url,$keyword,$title,$isPrivate)
Write-Host -ForegroundColor Green " A new Tag named " $keyword " is created successfully for the URL : " $url
## $tag is of Type: [SocialDataService Web service].SocialTagDetail()
##[SocialDataService Web service].SocialTagDetail() - Refer http://msdn.microsoft.com/en-us/library/websvcsocialdataservice.socialcommentdetail_members.aspx
}
}
#----------------Calling the function------------------------------------------------------------
CreateMultipleTags
CreateMultipleTags.xml
The Xml file contains all the information related to the social tag that has to be created to the specified url.


Join the conversation! Your thoughts help the community grow.