Created
December 1, 2015 23:39
-
-
Save anonymous/8968bb5c08d2210c2873 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-PSSnapin "Microsoft.SharePoint.Powershell” –ErrorAction SilentlyContinue | |
#Variables start | |
$siteUrl = "http://intranet.ul.com/” | |
$termSetStoreDesc = "Managed Metadata Service” | |
$groupDesc = "SDC” | |
$termSetName = "Geographies” | |
$saveLoc = "D:\MigrationScripts\MMS\TermsSets_GUIDs\SDCXML.xml” | |
$session = new-object Microsoft.SharePoint.Taxonomy.TaxonomySession($siteUrl) | |
#Variables end | |
$XML = "<?xml version='1.0'?>” | |
$termStore = $session.TermStores[$termSetStoreDesc] | |
$XML += "<TermStore Name='" + $termStore.Name + "' GUID='" + $termStore.ID + "'>” | |
$group = $termStore.Groups[$groupDesc] | |
$XML += "<Group Name='" + $group.Name + "' GUID='" + $group.ID + "'>” | |
$termSet = $group.TermSets[$termSetName] | |
$XML += "<TermSetGroup Name='" + $termSet.Name + "' GUID='” + $termSet.ID + "'>” | |
$terms = $termSet.GetTerms(200) | |
function RenderTerm($term) | |
{ | |
$result = "<Term><Name>” + $term.Name + "</Name><GUID>” + $term.ID + "</GUID>” | |
If ($term.TermsCount –gt 0) | |
{ | |
$result += "<ChildTerms>” | |
Foreach ($childTerm in $term.Terms) | |
{ | |
$result += RenderTerm($childTerm) | |
} | |
$result += "</ChildTerms>” | |
} | |
$result += "</Term>” | |
return $result | |
} | |
Foreach ($term in $terms) | |
{ | |
$XML += RenderTerm($term) | |
} | |
$XML += "</TermSet></TermSetGroup></TermStore>” | |
$XML | out-File –FilePath $saveLoc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment