SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When using managed metadata, how can I find out, if a term is used (and if possible, how often it is used), without iterating all sites and lists/libraries on the sites?

share|improve this question
This is fantastic, but how would you find out what the code would be if you wanted it to also mark what the term set or group it is in? – user34167 Oct 9 '14 at 20:53
up vote 1 down vote accepted

So, this is my own approach, it is iterating the site collections, but not their contents. It just checks the TaxonomyHiddenList for the terms it contains.

But if someone has a better idea, I would happily accept it :)

$usedTerms = @{}
Get-SPSite -Limit All | foreach {
    $web = $_.OpenWeb()
    $list = $web.Lists | where { $_.Title -eq "TaxonomyHiddenList" }
    $list.Items | foreach {
        if ($_ -ne $null)
            $key = ($_["Path"] + " (" + $_["IdForTerm"] + ")")
            if ($usedTerms.ContainsKey($key))
                $usedTerms[$key] = ($usedTerms[$key] + ", " + $web.Url)
                $usedTerms.Add($key, $web.Url)

share|improve this answer
The taxonomyhiddenlist can also contain items which were previously used, but not in use any more. So be aware that this approach might get you false positives. Another approach might be to leverage the search engine, you can use the TaxCatchAll field to search for term usage. – Jasper Aug 26 '15 at 5:50
@Jasper, good point, thanks for the warning. If you elaborate your approach in an answer I try and accept it as answer. – Hinek Oct 6 '15 at 6:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.