Consider the following TermStore as shown in the figure:























The following PowerShell code shows how to iterate through the above TermStore and find the term "Durban":
$siteCollectionUrl = "http://sp2010:90"
$site =new-object Microsoft.SharePoint.SPSite($siteCollectionUrl)
$session = New-Object Microsoft.SharePoint.Taxonomy.TaxonomySession($site)
$termStore = $session.TermStores[0]
$group = $termStore.Groups["Corporate Taxonomy"]
$termSet = $group.TermSets["Geography"]
$terms = $termSet.GetAllTerms()
foreach ($term in $terms)
{
    if ($term.Name -eq "Durban")
    {
        Write-Host "Drban Found!"
    }
}
Here TermSet.GetAllTerms() returns a collection containing a flat list of all Term objects in the TermSet object.


0 comments

My SharePoint CodePlex Projects

SharePoint 2010 Autocomplete Lookup Field

Export Version History Of SharePoint 2010 List Items to Microsoft Excel.