SharePoint 2013 TermSet with PowerShell

Create new script with following code:

$session = Get-SPTaxonomySession -Site "Your site Url"
$termStore = $session.TermStores[“Managed Metadata Application”] - change your managed metadata service name
$group = $termstore.CreateGroup(“My New Group”)
$group.Description = "My Term Group"
$termSet = $group.CreateTermSet(“My TermSet”,1033)
$termSet.Description = My TermSet
$termSet.IsAvailableForTagging = $true
$termSet.IsOpenForTermCreation = $true

To enable the term set for navigation, i.e  "Use this Term Set for Site Navigation" 
use following code to make it enabled.

$navigationSet = $group.CreateTermSet($termsetName)
 $navigationSet.SetCustomProperty("_Sys_Nav_IsNavigationTermSet", "True")
 $navigationSet.SetCustomProperty("_Sys_Nav_AttachedWeb_SiteId", $site.ID.ToString())
 $navigationSet.SetCustomProperty("_Sys_Nav_AttachedWeb_WebId", $site.RootWeb.ID.ToString())    
 $navigationSet.SetCustomProperty("_Sys_Nav_AttachedWeb_OriginalUrl", $site.RootWeb.Url )
You can check your new termset inside "My New Group" : go to  site management -> Term Store Management. 


  1. Hi, Anuja. This is a nice post. Do you know, though, that if you attach this termset to a site it cannot be used again by another site for navigation. What you want to do is make a new termset in your site collection termset (look at the list of groups in your termstore) and then copy terms to it. This way you can reuse the terms over and over. It isn't many more lines of code.


Post a Comment

Popular posts from this blog

Search Query by ContentType name issue

Search Result Webpart,Filter result If QueryString is present in URL

SharePoint 2013 List CRUD operation using Angular and REST API