SharePoint Online: Export-Import Term Store data using PowerShell
Requirement: Export and Import Term group, term set, and terms data from an XML file to SharePoint Online using PnP PowerShell.
How to Export and Import Term Store Data using PowerShell?
SharePoint Online’s term store is a powerful tool for managing and organizing metadata and taxonomy within an organization. However, there may be situations where you need to export and import term store data between SharePoint Online tenants. In this guide, we will outline the steps for exporting and importing term store data in SharePoint Online using PowerShell. By following these steps, you can easily transfer term store data between tenants (or backup-restore term store in the same tenant), saving time and reducing the effort required for manual transfer.
Export Term Store Data to XML File:
Use the Export-PnPTermGroupToXml cmdlet to export the Term Store data to XML:
Export-PnPTermGroupToXml -Out C:\Temp\Taxonomy.xml
This cmdlet exports all term groups, Term sets, and terms from the term store.
<pnp:TermGroups xmlns:pnp="https://schemas.dev.office.com/PnP/2018/07/ProvisioningSchema">
<!-- Term Group -->
<pnp:TermGroup Name="Deals Pipeline" Description="">
<pnp:TermSets>
<!-- Term Set 1 -->
<pnp:TermSet Name="Region" Description="">
<pnp:Terms>
<pnp:Term Name="Africa" />
<pnp:Term Name="Asia" />
<pnp:Term Name="Australasia" />
<pnp:Term Name="Europe" />
<pnp:Term Name="MENA" />
<pnp:Term Name="America" />
</pnp:Terms>
</pnp:TermSet>
<!-- Term Set 2 -->
<pnp:TermSet Name="DealStage" Description="">
<pnp:Terms>
<pnp:Term Name="Deal Identification" />
<pnp:Term Name="Screening IC" />
<pnp:Term Name="Post Screening IC" />
<pnp:Term Name="Final IC" />
<pnp:Term Name="Pre-Closing IC" />
<pnp:Term Name="Signed" />
<pnp:Term Name="ParCo" />
</pnp:Terms>
</pnp:TermSet>
</pnp:TermSets>
</pnp:TermGroup>
</pnp:TermGroups>
PnP PowerShell to Import Term store data from XML:
Use this PnP PowerShell script to import term store data:
#Config Variables
$AdminCenterURL = "https://Crescent-admin.sharepoint.com"
$XMLPath = "C:\Temp\Taxonomy.xml"
#Connect to PnP Online
Connect-PnPOnline -Url $AdminCenterURL -Interactive
#Import Term store Group, Term Set and Terms from XML
Import-PnPTermGroupFromXml -Path $XMLPath
And the result:
In conclusion, exporting and importing term store data in SharePoint Online using PowerShell is a quick and efficient way to transfer data between tenants. By connecting to SharePoint Online and exporting term store data using PnP PowerShell, administrators can export and import term store data with ease. Whether you are a seasoned administrator or just starting out, the ability to transfer term store data using PowerShell is a valuable tool in your SharePoint Online arsenal.