Wednesday, March 4, 2015

SharePoint 2013 - edit navigation term with powershell

I had a requirement to edit a term for a site with powershell to set the "Change target page for this term" property for a term-driven page.

The powershell I used is:

$site = Get-SPSite $portalUrl
$taxSession = Get-SPTaxonomySession -Site $site
$termStore = $taxSession.TermStores[$managedMetadataService]
$termStoreGroup = $termStore.Groups[$termStoreGroup]
$termSet = $termStoreGroup.TermSets[$termSet]
$term = $termSet.Terms.Item($term)
$term.SetLocalCustomProperty("_Sys_Nav_TargetUrl", $newUrl)
$termStore.CommitAll()

No comments: