Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

1 Answer 1

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 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 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.