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
$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:)