SharePoint Online: Configure Term Set Name, Description, Tagging Options using PowerShell

Requirement: Set Term Set Name, Description, Tagging Options using PowerShell in SharePoint Online.
sharepoint online powershell to set term set name, description and tagging options

SharePoint Online: Set Term Set Name, Description, Tagging Options using PowerShell
#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.sharepoint.com"
$TermGroupName = "Sectors"
$TermSetName = "Energy"

$TermSetNewName = "Energy Sector"
$TermSetDescription = "Term Set for Energy Apps"
$AvailableForTagging = $False

#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()

    #Set Term Set Name, description, Available For Tagging options
    $Termset.Name = $TermSetNewName
    $TermSet.Description = $TermSetDescription
    $TermSet.IsAvailableForTagging = $AvailableForTagging
    $Ctx.ExecuteQuery()
    Write-host -f Green "Term Set Settings Updated Successfully!"
}
Catch {
    write-host -f Red "Error: " $_.Exception.Message
} 
SharePoint Online: Configure Term Set Name, Description, Tagging Options using PowerShell SharePoint Online: Configure Term Set Name, Description, Tagging Options using PowerShell Reviewed by Salaudeen Rajack on July 08, 2018 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.