Using PowerShell to upload hierarchical Term Store in SharePoint

The SharePoint Term Store has emerged as an important feature that is used extensively nowadays for various configuration options. For example, Term Store is used to store custom navigation items, custom left navigation items, and custom quick link items. It is even extensible, used to store constants for list columns, and act as a master data store for them. There are various other scenarios, where Term Store has come in handy.

Add Data to Term Store Using PowerShell
There is a challenge associated with large amounts of Term Store data population or manipulation. Out of the box, SharePoint provides an upload through xml or csv formats. But when using custom solutions, adding Term Store data using code/PowerShell becomes handier in terms of deployment.

In this article, we will see how to add data to term store using power shell. We will follow the similar approach as we used in adding lists/ libraries.

We will first create an xml and store the terms. Then our PowerShell script will read the xml, create the term store and add the terms.

We will consider a very simple term store to start with. Let us define the xml for the term store. Let us keep isAvailableForTagging attribute as part of the xml, so that the property can be set for each term:

Now let us write the script to create a term store using the above xml.
We will keep the script generic such that any properly structured xml can be imported to the store. The script code is self-explanatory.

Once the simple Term Store is created, it is recommended that you have more terms and groups and subgroups on the xml and play around with them.

August 11, 2015