SharePoint Term Store - Used/Unused Terms

Viddy9 61 Reputation points
2021-08-04T10:58:27.41+00:00

Is it possible to see which terms have been used or not used across a SharePoint 2013 Farm?

Microsoft 365 and Office | SharePoint Server | For business
Microsoft 365 and Office | SharePoint Server | Development
{count} votes

Accepted answer
  1. Yi Lu_MSFT 17,616 Reputation points
    2021-08-06T09:10:53.29+00:00

    Hi @Viddy9
    We can use the following powershell to get a report of terms used in a site collection. If you want to check it in a farm, it’s necessary to loop through all sites in current farm.

    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue  
      
    $SiteCollURL="https://portal.crescent.com"  
    $ReportOutput="c:\MMS-Terms-Usage.csv"  
      
    $WebsColl = (Get-SPSite $SiteCollURL).AllWebs  
      
    #Array to hold Results  
    $ResultColl = @()  
      
    #Loop through each site, List and Fields  
    Foreach($web in $WebsColl)  
        {  
            Write-host "Scanning Web:"$Web.URL  
            Foreach($list in $web.Lists)             
            {  
                #Get all Managed metadata fields  
                Foreach($Field in $list.Fields | where {$_.GetType().Name -eq "TaxonomyField"})  
                    {  
                        Foreach ($item in $list.Items)  
                        {  
                            #Get All values of MMS field  
                            $MMSFieldValueColl = $item[$Field.Title] #-as [Microsoft.SharePoint.Taxonomy.TaxonomyFieldValueCollection]  
                               
                            #concatenate each term in the collection  
                            $MMSFieldTerms=[string]::Empty  
                            Foreach ($MMSFieldValue in $MMSFieldValueColl)  
                            {  
                                if($MMSFieldValue.label -ne $null)  
                                {  
                                    $MMSFieldTerms+=$MMSFieldValue.label+";"  
                                }  
                            }  
                               
                            #Collect the result  
                            if($MMSFieldTerms -ne '')  
                            {  
                                $Result = New-Object PSObject  
                                $Result | Add-Member -type NoteProperty -name "MMs Column Name" -value $Field.Title  
                                $Result | Add-Member -type NoteProperty -name "MMS Column Value" -value $MMSFieldTerms  
                                #Get the URL of the Item  
                                $ItemURL= $Item.ParentList.ParentWeb.Site.MakeFullUrl($item.ParentList.DefaultDisplayFormUrl)  
                                $ItemURL=$ItemURL+"?ID=$($Item.ID)"  
                                $Result | Add-Member -type NoteProperty -name "Item URL" -value $ItemURL  
                                $Result | Add-Member -type NoteProperty -name "List Name" -value $List.Title  
                                $Result | Add-Member -type NoteProperty -name "List URL" -value "$($List.ParentWeb.Url)/$($List.RootFolder.Url)"  
              
                                $ResultColl += $Result  
                            }  
                        }  
                    }  
            }  
        }  
      
    #Export Results to a CSV File  
    $ResultColl | Export-csv $ReportOutput -notypeinformation  
    Write-Host "Managed Metadata columns usage Report has been Generated!" -f Green  
      
    *************************************************************************  
    

    If an Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.