当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] SharePoint Online:如何使用 PowerShell 弃用术语库中的托管元数据术语?

作者:精品下载站 日期:2024-12-14 14:43:00 浏览:13 分类:玩电脑

SharePoint Online:如何使用 PowerShell 弃用术语库中的托管元数据术语?


SharePoint Online 中的托管元数据术语库提供了一种使用预定义术语对数据进行分类和增强搜索结果的绝佳方法。但是,在某些情况下,您可能需要删除使用的术语。因此,如果您决定停用某个术语 - 不要删除它们,而是弃用它们。弃用某个术语会阻止该术语进一步使用,并且不会影响已经使用该特定术语的所有项目!当您决定弃用不再使用或将来不应使用的术语时,请按照以下步骤操作!

如何弃用托管元数据术语库中的术语?

以下是如何弃用 SharePoint Online 术语库中的术语:

  1. 登录 SharePoint Online 管理中心 >> 展开“内容服务”,然后单击左侧导航中的“术语存储”。
  2. 遍历到您想要弃用的特定术语。
  3. 选择术语,单击向下的小箭头,然后从上下文菜单(或工具栏!)中单击“弃用术语”选项。

    [玩转系统] SharePoint Online:如何使用 PowerShell 弃用术语库中的托管元数据术语?

已弃用的术语会以红色小图标显示并变暗,并且已弃用的术语不能在新项目中使用。

启用已弃用术语(未弃用):

如果您决定重新启用已弃用的术语,您只需从特定术语的上下文菜单中单击“启用术语”选项即可。

[玩转系统] SharePoint Online:如何使用 PowerShell 弃用术语库中的托管元数据术语?

如何使用 PowerShell 弃用 SharePoint Online 术语库中的术语?

现在,让我们使用 CSOM-PowerShell 脚本弃用一个术语。


#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll"
 
#Set parameter values
$SiteURL="https://crescent.sharepoint.com/"

#Termset parameters
$TermGroupName="Regions"
$TermSetName="MENA"
$TermName="UAE"

Try { 
        #Get Credentials to connect
        $Cred= Get-Credential
        $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
 
        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = $Credentials

        #Get the Taxonomy Session
        $TaxonomySession = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($Ctx);
        $TermStore =$TaxonomySession.GetDefaultSiteCollectionTermStore()
        $Ctx.Load($TaxonomySession)
        $Ctx.Load($TermStore)
        $Ctx.ExecuteQuery()

        #Get the Term Group    
        $TermGroup = $TermStore.Groups.GetByName($TermGroupName)
        $Ctx.Load($TermGroup)

        #Get the termset
        $TermSet = $TermGroup.TermSets.GetByName($TermSetName)
        $Ctx.Load($TermSet)
        
        #Get the term
        $Term = $TermSet.Terms.GetByName($TermName) 
        $Ctx.Load($Term)
        $Ctx.ExecuteQuery()
       
        #Deprecate the Term
        $Term.Deprecate($True) #$False - Enables the Term back
        $Ctx.ExecuteQuery()

        Write-host -f Green "Term has been Deprecated successfully!"
     }
    Catch {
        write-host -f Red "Error Deprecating Term!" $_.Exception.Message
   }

PnP PowerShell 弃用 SharePoint Online 中的术语

托管元数据术语可以在 SharePoint Online 的术语库中弃用,以指示它不再使用。已弃用的术语被标记为非活动状态,无法再选择或添加到项目中。以下是用于弃用术语库中托管元数据术语的 PnP PowerShell 脚本:


#Parameters
$AdminCenterURL = "https://Crescent-Admin.sharepoint.com"
$TermName = "DevOps Engineer"
$TermSetName = "Job Titles"
$TermGroupName = "Deals Pipeline"

#Deprecate a Term
Set-PnPTerm -Identity $TermName -TermSet $TermSetName -TermGroup $TermGroupName -Deprecated $true

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯