Microsoft 365 : SharePoint online – PowerShell – how to know in which Site Collection the termset (taxonomy term) is used

fig : Microsoft 365 - SharePoint Online - Getting the term id
fig : Microsoft 365 - SharePoint Online - Getting the term id

Hi All,

Greetings for the day!!!

Today again small article but very useful one

Background / Details

  • In our tenant, we have did modification to Term Sets – we renamed couple of TermSet / Terms. Since we are only renaming, IDs are same
  • We have thousands of site collections in our Tenant, we want to make sure that renaming TermSets / Terms is not impacting any site collection / not breaking anything
  • So we want to find the list of site collection where the respective termsets / term is used

Finding the site collections where Term Set is used

  • There are multiple approaches to do this
  • Using Hidden Taxonomy List
fig : Microsoft 365 - SharePoint Online - Taxonomy Hidden List
fig : Microsoft 365 – SharePoint Online – Taxonomy Hidden List URL
  • Using Search
    • While bit googleing this I found very useful PnP powershell CMDLET – Submit-PnPSearchQuery
    • This CMDLET search across the SharePoint index

Finding where TermSet / Term is used in SharePoint using Search

  • When we add Term to metadata column in either List or Document Library, along with Label of Term, Term ID and TermSet ID also get indexed so that they are searchable
  • We will search with Term ID, we can get Term ID from the Term Store Manager as
    • Navigate to Term Store from – Site Settings >> Site Administration >> Term Store Manager
    • Navigate to respective term
fig : Microsoft 365 - SharePoint Online - Navigating to Term store manager
fig : Microsoft 365 – SharePoint Online – Navigating to Term store manager
  • On click of “Term store management” link we will be redirected to “TermStoreAdminCenter” page as shown in below fig
  • Navigate the TermSet / Term of which we need ID
  • After selecting respective TermSet / Term, click on “Usage settings” tab under which we have “Unique identifier” as shown in below fig
fig : Microsoft 365 - SharePoint Online - Getting the term id
fig : Microsoft 365 – SharePoint Online – Getting the term id
  • Once we have “TermID” we could use it with our search CMDLET
  • Following is the PnP search CMDLET

Submit-PnPSearchQuery -Query "2944cfb5-bdf4-4f75-8d83-24ef990f25b9"


GroupTemplateId              :
ItemTemplateId               :
Properties                   : {[RenderTemplateId, ~sitecollection/_catalogs/masterpage/Display Templates/Search/Group_Default.js], [QueryModification, 2944cfb5-bdf4-4f75-8d83-24ef990f25b9
                               -ContentClass=urn:content-class:SPSPeople], [ExecutionTimeMs, 0], [StartRecord, 0]...}

QueryId                      : 82709606-fdb4-4022-958a-fbff75ef152c
QueryRuleId                  : 00000000-0000-0000-0000-000000000000

ResultRows                   : {System.Collections.Generic.Dictionary`2[System.String,System.Object], System.Collections.Generic.Dictionary`2[System.String,System.Object],
                               System.Collections.Generic.Dictionary`2[System.String,System.Object], System.Collections.Generic.Dictionary`2[System.String,System.Object]...}
ResultTitle                  :
ResultTitleUrl               :

RowCount                     : 500
TableType                    : RelevantResults
TotalRows                    : 4058
TotalRowsIncludingDuplicates : 4058
TypeId                       : {6780df59-1036-4912-829b-432354f22656}

  • Above query returns first 500 result along with TotalRows as shown in above code block
  • To get list of all site collections where this term set id is used, we will use value for “CollapseSpecification” property to “SPSiteURL:1” – here SPSiteURL is managed property
  • So respective CMDLET will be

Submit-PnPSearchQuery -Query "2944cfb5-bdf4-4f75-8d83-24ef990f25b9" -CollapseSpecification "SPSiteUrl:1" -RelevantResults

  • We will get the detailed output like

WorkId                     : 396051648703373191
Rank                       : 994.1509332
Title                      : slides.pptx
Author                     : Author
Size                       : 3371569
Path                       : https://knowledgejunction1.sharepoint.com/slides.pptx
Description                :
Write                      : 7/1/2020 3:44:18 PM
CollapsingStatus           : 1

HitHighlightedSummary      : PowerPoint Presentation

contentclass               : STS_ListItem_DocumentLibrary

PictureThumbnailURL        : https://knowledgejunction1.sharepoint.com/_api/v2.1/drives/b!8IpN57pMiE6-5nTKqXhRXP4NZ7pjfdNKt_ulc0nFSS87g5qNsbo_TKNat2BFXosd/items/0163RHDH7B5MHJFMH455AY5G5X6HCB2E72/thumbnail

FileExtension              : pptx

ContentTypeId              : 0x01010040904BFEE18AAD4FB9F450ADA8644770002700FB7F91F36C40BA932768ED5AF5B300B23B8A786498CF46BB36179F956E0386

ViewsLifeTime              : 24
ViewsRecent                : 4
SectionNames               :
SectionIndexes             :
SiteDescription            :
deeplinks                  :
importance                 : 0
IsDocument                 : True
LastModifiedTime           : 7/1/2020 3:44:18 PM
FileType                   : pptx
IsContainer                : False
WebTemplate                :
ResultTypeIdList           :
ResultTypeId               :
SecondaryFileExtension     : pptx
RenderTemplateId           :
DocId                      : 396051648703373191
docaclmeta                 :
UniqueId                   : {920eebe1-fcb0-41ef-8e9b-b7f1c41d13fa}
ProgId                     :
GeoLocationSource          : NAM
SiteId                     : e74d8af0-4cba-4e88-bee6-74caa978515c
WebId                      : ba670dfe-7d63-4ad3-b7fb-a57349c5492f
IsExternalContent          : False
ListId                     : 8d9a833b-bab1-4c3f-a35a-b760455e8b1d
PartitionId                :
UrlZone                    : 0
Culture                    :

WorkId                     : 396051666837781781
Rank                       : 994.1478266
Title                      : PI Newsletter July 2020
Size                       : 248848
Description                :
Write                      : 8/6/2020 11:46:28 AM
CollapsingStatus           : 1
HitHighlightedProperties   :
contentclass               : STS_ListItem_DocumentLibrary
FileExtension              : pdf
ContentTypeId              : 0x01010040904BFEE18AAD4FB9F450ADA8644770002700FB7F91F36C40BA932768ED5AF5B30045D0E8245066FE4F8C513F5D0B0C1C4F
ViewsRecent                : 3
SectionNames               :
SectionIndexes             :
SiteDescription            :
deeplinks                  :
importance                 : 0
IsDocument                 : True
LastModifiedTime           : 8/6/2020 11:46:28 AM
FileType                   : pdf
IsContainer                : False
WebTemplate                :
ResultTypeIdList           :
ResultTypeId               :
SecondaryFileExtension     : pdf
RenderTemplateId           :
DocId                      : 396051666837781781
docaclmeta                 :
ProgId                     :
LinkingUrl                 :
piSearchResultId           : ARIAǂ214fd337-8ee7-ef13-b97a-6c3680b1c4a0ǂ5c1d2299-916d-4c9f-9a66-85c844c4a0c1ǂ214fd337-8ee7-ef13-b97a-6c3680b1c4a0.1000.500ǂ
GeoLocationSource          : NAM
SiteId                     : e74d8af0-4cba-4e88-bee6-74caa978515c
WebId                      : ba670dfe-7d63-4ad3-b7fb-a57349c5492f
IsExternalContent          : False
ListId                     : 2fa25176-445d-4c24-867f-0983749899b5
PartitionId                :
UrlZone                    : 0
Culture                    :

  • Here we will get all site URLs where the respective term is used

REFERENCES

Thanks for reading the article !!! Please feel free to discuss in case any issues / suggestions / thoughts / questions !!!

HAVE A GREAT TIME AHEAD !!! LIFE IS BEAUTIFUL 🙂

Prasham Sabadra

LIFE IS VERY BEAUTIFUL :) ENJOY THE WHOLE JOURNEY :) Founder of Knowledge Junction and live-beautiful-life.com, Author, Learner, Passionate Techie, avid reader. Certified Professional Workshop Facilitator / Public Speaker. Scrum Foundation Professional certificated. Motivational, Behavioral , Technical speaker. Speaks in various events including SharePoint Saturdays, Boot camps, Collages / Schools, local chapter. Can reach me for Microsoft 365, Azure, DevOps, SharePoint, Teams, Power Platform, JavaScript.

You may also like...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: