SharePoint Online / Office 365 : Exporting all the Terms from particular TermSet in .csv file using CSOM + PowerShell
Today In this article I will explain in detail how to export all the terms from given TermSet in .CSV file using CSOM + PowerShell. This PowerShell script is applicable for SharePoint Online / Office 365 site.
Scenario : We have our SharePoint online site. We are using TermSets in one of the our project. We have one TermSet called “Department” having around 40-50 terms (each term is a one department). There are sudden change in the department names, so our customer want to go through each term and want to correct those.
Here, one option is give the rights to the customer so that they can go to “Term Store Management” page (_layouts/15/termstoremanager.aspx) and change the default label for the terms which they want to change. But this is not the best approach. This approach may be confusing for non technical customer.
So best alternative we thought that we will provide TermSet in .CSV file (excel) and give it to the customer, they will do respective changes and send back to us so that we can directly import those.
But again, OOB there is no option to Export the given TermSet as shown in Figure 1 and copying manually each term is not the best possible solution again.
Figure 1 : No “Export Term Set” option
So one of the best possible approach is to write our own PowerShell script and export the trems of TermSet in .CSV file.
PowerShell script Step By Step :
Step 1 : Load the Taxonomy library as
#Load the Taxonomy library
Add-Type-Path"c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll" # Path to Taxonomy library (where client SDK is installed)
Step 2 : Set the required variables like SiteCollection URL from where we need to export the TermSet, UserName and Password of your site to connect as
#Site collection URL from where we need to export the TermSet
$siteurl = ""# Your site collection URL
#User name and Passwords
$userName =""# Your user name
$password =""# Password
Step 3 : Get theMicrosoft.SharePoint.Client.ClientContextinstance and set the credentials as
#client context object and setting the credentials