SharePoint Online: How to Rename a Term in the Term Store using PowerShell?
Requirement: Rename a Term in SharePoint Online Term store using PowerShell.
How to rename a Term in SharePoint Online Term Store?
The term store, also known as the managed metadata service, is a key component of SharePoint Online that allows administrators to create, manage, and reuse metadata across the organization. In this post, we will discuss how to rename a term in the SharePoint Online term store.
To rename a term in the SharePoint Online Term Store, you can follow these steps:
- Login to SharePoint Online Admin Center >> Click on the “Term store” link under “Content Services” from the left navigation.
- Expand term groups, Term Sets and pick the target term to change the term name.
- Click on “Rename Terms” from the toolbar >> Enter the new name for your term.
- Hit save to commit your changes.
SharePoint Online: Update Term Name using PowerShell
This PowerShell script updates the default label for a given term and adds synonyms.
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll"
#Set Variables
$SiteURL= "https://crescent-admin.sharepoint.com"
$TermGroupName = "Regions"
$TermSetName = "Africa"
$TermName="Namibia"
#Setup Credentials to connect
$Cred = Get-Credential
Try {
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
#Get the Taxonomy Session and Term Store
$TaxonomySession = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($Ctx)
$TaxonomySession.UpdateCache()
$Ctx.Load($TaxonomySession)
$TermStore = $TaxonomySession.GetDefaultSiteCollectionTermStore()
$Ctx.Load($TermStore)
$Ctx.ExecuteQuery()
#Get the Term Group
$TermGroup = $TermStore.Groups.GetByName($TermGroupName)
$Ctx.Load($TermGroup)
#Get the Term Set
$TermSet = $TermGroup.TermSets.GetByName($TermSetName)
$Ctx.Load($TermSet)
$Ctx.ExecuteQuery()
#Get the term
$Term = $TermSet.Terms.GetByName($TermName)
$Ctx.Load($Term)
$Ctx.ExecuteQuery()
#Update Default Label of the Term
$DefaultTermLabel = $Term.CreateLabel("Namibians", 1033, $True)
#Add Synonyms
$OtherTermLabel = $Term.CreateLabel("South West Africa", 1033, $False)
$OtherTermLabel = $Term.CreateLabel("Suidwesafrica", 1033, $False)
$Ctx.ExecuteQuery()
Write-host -f Green "Term Name has been updated!"
}
Catch {
write-host -f Red "Error: " $_.Exception.Message
}
PnP PowerShell to Rename a Term in SharePoint Online
Here is the PnP PowerShell script to change the name for a Term:
#Parameters
$AdminCenterURL = "https://crescent-admin.sharepoint.com"
#Connect to Admin Center
Connect-PnPOnline -Url $AdminCenterURL -Interactive
#Rename Terms
Set-PnPTerm -Identity "Namibia" -TermSet "Africa" -TermGroup "Regions" -Name "Namibians"
In summary, Renaming a term in the SharePoint Online term store is a straightforward process through SharePoint Admin Center. With the Term store Administrator permissions, you can easily access the Term Store, change the name of a term to better reflect its meaning or to keep your metadata up to date. By following the steps outlined in this tutorial, you can quickly and effectively rename a term in the SharePoint Online term store.
Hi, How can we achieve this using PnP Powershell?