Import/Export taxonomy data in SharePoint Online

By | March 3, 2019

Issue with available PowerShell cmdlets:

I implemented a PS script with available PowerShell cmdlets to import/export term store data. When I executed the export script first against a SharePoint Online site collection, export was successful. But all the terms were not exported.

The terms beginning with hyphen and contains space were not exported.

Issue Term: “- termname”


So I re-implemented the script using PnP PowerShell cmdlets and PnP cmdlets fixed the issue. I must appreciate PnP guys, as they are making developers life easier.

So here is Script.

#Export terms PS script

#Define Variables to process

$siteCollectionUrl = “https://sitecollectionURL

$filePath = “C:\TermGroup.xml”



#Connect to SPO site

Connect-PnPOnline -Url $siteCollectionUrl

#Get Context

$ctx = Get-PnPContext

#Export the terms to XML file

Export-PnPTermGroupToXml -Out $filePath

Write-host “Term Store Data Successfully Exported!” -ForegroundColor Green




write-host -f Red “Error Exporting Termstore Data!” $_.Exception.Message

write-host -f Red “Stack Trace: ” $_.Exception.StackTrace

Hope it helps someone. Sharing is Caring:)

One thought on “Import/Export taxonomy data in SharePoint Online

  1. Kara Acerno

    you are in reality a good webmaster. The site loading velocity is incredible. It sort of feels that you are doing any unique trick. In addition, The contents are masterpiece. you have performed a fantastic activity on this matter!


Leave a Reply

Your email address will not be published. Required fields are marked *