Saturday, March 23, 2013

Export Term Store to xml using PowerShell

This seemed so obvious while using Central Admin, but soon I realized that there is so much left for SharePoint team at Microsoft to accomplish.

I needed to discuss the Site Taxonomy with my colleagues during our weekly call, when suddenly I found myself searching for the script that would do the magic.

TechNet has this:

http://social.technet.microsoft.com/wiki/contents/articles/17874.sharepoint-2010-how-to-manage-the-term-store-via-powershell.aspx

Gary LaPointe has this:

http://blog.falchionconsulting.com/index.php/2012/03/exporting-and-importing-sharepoint-2010-terms/

Thanks to the above. This was sufficient for me to quickly get my script in-place:

Export-SPTerms  -Group (Get-SPTaxonomySession -Site "http://mydomain/sites/cthub").TermStores[0].Groups[2] -OutputFile "D:\CTHubExport\site_terms.xml" –Verbose

You probably will need to work with the parameters for TermStores[0] & Groups[2] to see that you are correctly referring to your Term Store and the needed Group within the TermStore.

This generated a beautifully formatted xml file.