Automation: Create a Social Tag in
SharePoint 2010 using PowerShell
A Social Tag can be created for any specified URL with a valid term using the SocialTagManager object. SocialTagManager object contains methods and properties
that are used to manipulate social tag data.
Steps Involved:
- Create the input xml file which contains the inputs for creating social tag.
- Create a ps1 file which contains the script for creating social tag.
CreateSocialTag.xml
<?xml
version="1.0"
encoding="utf-8"
?>
<SocialTag>
<SiteURL>
https://serverName.com/Finance/Finance/</SiteURL>
<Uri>https://serverName.com/Finance/Finance/</Uri>
<TermName>Sample
Tag</TermName
>
</SocialTag>
CreateSocialTag.ps1
## -------------------------------------------------------------------
## Powershell script for creating Social Tag
## Note : Need to update the XML file path before running the script.
## Author : Vijai Anand Ramalingam
## Date : 28-Oct-2011
## -------------------------------------------------------------------
#----------------Get the xml
file---------------------------------------------------------------
[xml]$xmlData=Get-Content
"D:\VijaiPOC\CreateSocialTag.xml"
#----------------Create Social Tag
function----------------------------------------------------
function
CreateSocialTag()
{
$uri
=
New-Object
System.Uri($xmlData.SocialTag.Uri);
$site
=
Get-SPSite
$xmlData.SocialTag.SiteURL
## Get the context of the service application
$context
=
Get-SPServiceContext($site)
## SocialTagManager - Contains methods and properties used to manipulate social
tag data
$socialTagManager
=
New-Object
-TypeName
Microsoft.Office.Server.SocialData.SocialTagManager
-ArgumentList
$context
## Retrieve the taxonomy session from the SocialTagManager.
$taxSession
=
$socialTagManager.TaxonomySession
$termStore
=
$taxSession.DefaultKeywordsTermStore




Dearbhla BradleyPosted Jul 21, 2014, 10:30 AM
Quick question, in the XML file, can you create multiple tags in there or is it just the one?