SharePoint Online:使用 PowerShell 更新术语集属性(名称、描述、标记选项等)
要求:使用 SharePoint Online 中的 PowerShell 更改术语集属性,例如名称、说明、标记等。
如何更新 SharePoint Online 中的术语集属性?
SharePoint Online 中的术语集是用于对网站上的内容进行分类的相关术语的集合。通过更新这些术语集,您可以使分类保持最新,并确保其准确反映内容的组织和分类。在本文中,我们将引导您完成在 SharePoint Online 中更新术语集的过程。
要更新 SharePoint Online 中的术语集,您可以按照以下步骤操作:
- 转到 SharePoint Online 管理中心 >> 展开“内容服务”并单击“术语库”。
- 在术语库管理页面中,导航到术语组并选择要更新的术语集。
单击工具栏中的“重命名术语集”按钮可更新所选术语集的名称和描述。
- 您还可以设置术语集属性上可用的各种属性,例如“可用于导航”、“可用于标记”等。
-
完成更改后,单击“保存”按钮保存更改。
请注意,您必须具有术语库管理员权限才能访问术语库管理页面并编辑术语集。
SharePoint Online:使用 PowerShell 设置术语集名称、说明和标记选项
在这篇博文中,我们将了解如何使用 PowerShell 更新 SharePoint Online 中的术语集。如果您需要通过脚本而不是标准浏览器界面更改术语集,这会派上用场。
以下是使用 PowerShell 更新 SharePoint Online 中的术语集的方法:
#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
}
PnP PowerShell 更新 SharePoint Online 中的术语集
PnP PowerShell 使其变得更加简单!通过使用 PnP PowerShell,您可以自动执行 SharePoint Online 中的术语集更新过程:
#Parameters
$AdminCenterURL = "https://crescent-admin.sharepoint.com"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
#Update Term set Name and description
Set-PnPTermSet -Identity "Africa" -TermGroup "Regions" -Name "African" -Description "African Continent"
#Update Term Set Tagging and Navigation options
Set-PnPTermSet -Identity "Top Navigation" -TermGroup "Global Top Navigation" -IsAvailableForTagging $True -UseForSiteNavigation $True
结论:
通过执行上述步骤,您可以轻松更新 SharePoint Online 中的术语集,以保持分类法的准确性和最新性。无论您是添加新术语、编辑现有术语还是更新术语集本身的属性,该过程都很简单。通过定期更新术语集,您可以确保您的 SharePoint Online 网站保持组织有序、结构良好且易于导航。通过使用 PowerShell 自动化该过程,您可以节省时间和精力。


