Pages

Wednesday 21 September 2011

Create a new term in Existing Group and Term Set Under Managed Metadata Service Application with PowerShell


Use this script if you want to create a new term in the SharePoint 2010 Managed Metadata Service with PowerShell:

#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
$termStore.CommitAll()

1 comment:

Popular Posts