Tuesday, 29 June 2010

Create a new Managed Metadata term with synonym in SharePoint 2010 using PowerShell

Use this script if you want to create a new term in the SharePoint 2010 Managed Metadata service with PowerShell. Incidentally, the Managed Metadata CSV import format provided out-of-the-box in SharePoint 2010 does not support synonyms, so you could easily use this code along with the Import-Csv PowerShell cmdlet to come up with a replacement format if you needed to support synonyms (will get around to posting a script at some point):

#Connect to Central Admin
$taxonomySite = get-SPSite http://centraladminsite:port

#Connect to Term Store in the Managed Metadata Service Application
$taxonomySession = Get-SPTaxonomySession -site $taxonomySite
$termStore = $taxonomySession.TermStores["Managed Metadata Service"]
write-host "Connection made with term store -"$termStore.Name

#Connect to the Group and Term Set
$termStoreGroup = $termStore.Groups["Group Name"]
$termSet = $termStoreGroup.TermSets["Term Set Name"]

#Create term, term description, and a synonym
$term = $termSet.CreateTerm("Test Term", 1033)
$term.SetDescription("This is a test", 1033)
$term.CreateLabel("This is a test synonym", 1033, $false)

#Update the Term Store

#Dispose of taxonomy site object


  1. I run this and i get an error saying "Cannot index into a null array". Any idea?

  2. Very informative post. I sometimes do presentations on SharePoint and was wondering if I could use your Print List example in my presentations and refer my audience to your website for further info.

  3. We prefer to honor several other net sites around the internet, even when they arent linked to us, by linking to them. Below are some webpages worth checking out.

  4. These exercises will permit you to create much more lean muscle throughout your complete body,
    so you lose fat in all your difficulty zones. Boneka Wisuda