Showing posts with label Term Store. Show all posts
Showing posts with label Term Store. Show all posts

Sunday, May 26, 2013

Export Term Store to csv using PowerShell

This is another approach towards exporting the term stores to a CSV file format using power shell. I have tried to modify and enhance my previous post to achieve this requirement of generating a  Microsoft Excel format.

So here it is.

#creating a header-row for the csv file

"termStore `t" + "termGroup `t" + "termGroup-LastModifiedDate `t" + "termSet `t" + "termSet-LastModifiedDate `t" + "termSetGUID `t" + "terms `t" + "termsGUID `t" + "terms-LastModifiedDate" >> C:\ExportTermStore.csv

$termSet = Get-SPTaxonomySession -Site http://mydomain/sites/cthub
$termStore = $termSet.TermStores[0]
$termStore.Groups | FT -Autosize Name
$termGroup = $termStore.Groups["myTermStoreGroupName"]   #This is the case when we know the name of the group and want just that. We can also have a foreach instead, to loop-through each of the TermStore Group. I chose the first.
$termStore = $termStore.Name #saving the termStore “Name” in the variable $termStore
$termGroup.TermSets | FT -Autosize Name

foreach ($termGroups in $termGroup.TermSets)
{
  foreach ($termSets in $termGroups.Terms)
  {
    foreach ($terms in $termSets.Terms)
    {
      $termStore + "`t" + $termGroups.Name + "`t" + $termGroups.LastModifiedDate + "`t" + $termSets.Name + "`t" + $termSets.LastModifiedDate + "`t" + $termSets.ID + "`t" + $terms.Name + "`t" + $terms.ID + "`t" + $terms.LastModifiedDate >> C:\ExportTermStore.csv
    }
  }
}

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.