Monday, September 14, 2015

Export Taxonomy Terms to SharePoint List


SharePoint give an option to have store metadata information. That's called Taxonomy. It's common place to have terms. Now i am going to give a script to export this terms to list.

Script

$site = Read-Host "Enter  Site URL :"
$web = Read-Host "Enter Sub Site URL :"
$spweb= Get-SPWeb $web
$country = $spweb.Lists["Your List Name"]

$termSet = Get-SPTaxonomySession -Site $site
$termStore = $termSet.TermStores[0]
$termGroup = $termStore.Groups[“TermGroupName”]
$termStore = $termStore.Name
foreach ($termGroups in $termGroup.TermSets)
{
    foreach ($termSets in $termGroups.Terms)
    {
        $newItem = $country.items.add()
        $newItem["Title"] = $termSets.Name
        $newItem.Update()
        Write-Host $termSets.Name " has been added !!!" -ForegroundColor Green
    }
}

That's all. Terms will be added in the list

1 comment: