Introduction To Term Store Management in SharePoint Online

Term Store refers to a centralized repository for managing and storing reusable metadata or business-related terms. The Term Store is primarily used to create and manage a taxonomy, which is a hierarchical structure of terms or labels that can be applied to content across a SharePoint environment.

Term Set

A term set is a collection of related terms. It's a way to group and organize terms based on common properties or categories. Each term set can have its own set of custom properties. For a blog, you might have term sets for "Categories," "Tags," or "Topics."

  • Local term sets: Created locally for site collection level, and it’s not accessible outside the site collection boundary.
  • Global term sets: Available across all sites and accessible to all site collection levels.

Term

A term refers to a keyword or label used to categorize and describe content within the context of the Term Store. If you work on a multilingual site, the term can have labels in different languages.

Term Group

Term Groups are handy when you want to keep different types of terms separate and well-organized within the SharePoint Term Store. They provide a way to manage and control access to sets of terms based on their common purpose or theme.

Creating a Term Group

The script connects to the SharePoint Online environment and creates a new Term Group named "Countries" with a description of "global countries." This centralized repository serves as a container for organizing and storing reusable metadata related to countries.

$AdminURL = "https://yourTenant-admin.sharepoint.com/"

$TermGroupName = "Countries"
$TermGroupDescription ="global countries"

Connect-PnPOnline -Url $AdminURL -Interactive

#Create new group in Termstore
New-PnPTermGroup -Name $TermGroupName -Description $TermGroupDescription
Write-Host -f Green "Term Group '$TermGroupName' created successfully!"

Creating a Term Set

After connecting to the SharePoint Online environment, the script creates a Term Set named "Region" within the previously established "Countries" Term Group. This Term Set provides a way to group and organize terms based on common properties or categories, in this case, regions.

$AdminURL = "https://yourTenant-admin.sharepoint.com/"

$TermGroupName = "Countries"
$TermSetName ="State"

Connect-PnPOnline -Url $AdminURL -Interactive

#Create new Term Set
New-PnPTermSet -Name "Region" -TermGroup $TermGroupName
Write-Host -f Green "Term Group '$TermSetName' created successfully!"

Creating a Term

The script connects to the SharePoint Online environment and checks if a term named "Maharashtra" already exists within the "State" Term Set of the "Countries" Term Group.

If the term does not exist, the script creates a new term with the name "Maharashtra," allowing for the categorization and description of content related to this term.

$AdminURL = "https://yourTenant-admin.sharepoint.com/"

$TermGroupName = "Countries"
$TermSetName = "State"
$TermName = "Maharashtra"

Connect-PnPOnline -Url $AdminURL -Interactive

$term = Get-PnPTerm -Identity $TermName -TermSet $TermSetName -TermGroup $TermGroupName -ErrorAction SilentlyContinue
if (!$term) {
    #Create new Term
    New-PnPTerm -Name $TermName -TermSet $TermSetName -TermGroup $TermGroupName
    Write-Host -f Green "Term '$TermName' created successfully!"
}
else {
    Write-Host -f Red "Term '$TermName' already exists!"
}

Conclusion

PowerShell scripts offer a streamlined and automated approach to managing Term Groups, Term Sets, and Terms in SharePoint Online using the PnP PowerShell module. In this blog post, I covered some common tasks for creating the term store with PowerShell, such as creating new term groups, term sets, and terms.