ค้นหาเว็บไซต์

SharePoint Online: ลบชุดคำโดยใช้ PowerShell


ความต้องการ: ลบชุดคำใน SharePoint Online

จะลบชุดคำใน SharePoint Online ได้อย่างไร

ใน SharePoint Online คุณสามารถลบชุดคำที่ไม่จำเป็นอีกต่อไปได้ การลบชุดคำสามารถช่วยให้คุณจัดระเบียบที่เก็บคำของคุณและลดความยุ่งเหยิงได้ ในบทความนี้ เราจะกล่าวถึงวิธีการลบชุดคำใน SharePoint Online

เมื่อต้องการลบชุดคำออกจากที่เก็บคำ SharePoint Online ให้ทำตามขั้นตอนเหล่านี้:

  1. เข้าสู่ระบบไซต์ศูนย์การจัดการ SharePoint Online ของคุณ (เช่น https://yourdomain-admin.sharepoint.com)
  2. ขยาย "บริการเนื้อหา" และคลิกลิงก์ "ที่เก็บคำ" บนเมนูการนำทางด้านซ้าย
  3. ตอนนี้ จากที่เก็บคำ คุณสามารถนำทางไปยังชุดคำที่คุณต้องการลบ และคลิก "ลบชุดคำ" จากเมนูบริบท
  4. ยืนยันป๊อปอัป "ลบชุดคำ" โดยคลิกปุ่ม "ลบ" การดำเนินการนี้จะลบข้อกำหนดทั้งหมดภายใต้ชุดคำที่ถูกลบ และข้อกำหนดใดๆ ที่ใช้งานจะถูกย้ายไปยัง "คำที่ถูกละเลย" ภายใต้กลุ่มคำ "ระบบ"

หลังจากลบชุดคำแล้ว คุณสามารถตรวจสอบได้ว่าถูกลบไปแล้วหรือไม่ โดยการรีเฟรชหน้าเครื่องมือการจัดการที่เก็บคำ และตรวจสอบว่าชุดคำนั้นไม่อยู่ในรายการอีกต่อไป คุณยังสามารถกลับไปยังกลุ่มที่มีชุดคำและยืนยันว่าชุดคำนั้นถูกลบไปแล้ว

คุณยังสามารถใช้ Term store แบบคลาสสิกได้จาก: คุณลักษณะเพิ่มเติม >> Term store ในการนำทางด้านซ้ายของศูนย์การจัดการ SharePoint (ทางลัด URL: https://tenant-admin.sharepoint.com/_layouts/15/TermStoreManager.aspx)

  1. จากมุมมองแผนผังอนุกรมวิธาน ให้ขยายและเลือกชุดคำที่คุณต้องการลบ คลิกที่ลูกศรเล็กๆ ในชุดคำ >> เลือกตัวเลือก "ลบชุดคำ"

  2. ยืนยันพร้อมท์หนึ่งครั้งเพื่อลบชุดคำออกจากที่เก็บคำของ SharePoint Online

PowerShell เพื่อลบชุดคำใน SharePoint Online

นอกจากนี้เรายังสามารถลบชุดคำโดยทางโปรแกรมโดยใช้ 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"
  
#Variables for Processing
$AdminURL = "https://crescent-admin.sharepoint.com/"
$TermGroupName ="Regions"
$TermsetName="MENA"

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($AdminURL)
    $Ctx.Credentials = $Credentials

    #Get the term store
    $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)

    #Get the term set to delete
    $TermSet = $TermGroup.TermSets.GetByName($TermsetName)

    #Delete the term set
    $TermSet.DeleteObject()
    $Ctx.ExecuteQuery()

    Write-host "Term Set '$TermSetName' Deleted Successfully!" -ForegroundColor Green
}
Catch {
    write-host -f Red "Error Deleting Term Set!" $_.Exception.Message
} 

ลบชุดคำทั้งหมดออกจากกลุ่มคำใน 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"
  
#Variables for Processing
$AdminURL = "https://crescent-admin.sharepoint.com/"
$TermGroupName ="Regions"

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($AdminURL)
    $Ctx.Credentials = $Credentials

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

    #Get the term group    
    $TermGroups = $TermStore.Groups
    $Ctx.Load($TermGroups)
    $Ctx.ExecuteQuery()
    $TermGroup = $TermGroups | Where-Object {$_.Name -eq $TermGroupName}
     
    If($TermGroup -ne $NULL)
    {
        #Delete all Term sets in the Term group
        $TermSets = $TermGroup.TermSets
        $Ctx.Load($TermSets)
        $Ctx.ExecuteQuery()

        #Delete all Term Sets from the Group
        $TermSets | Foreach-object {
            $_.DeleteObject()
            $Ctx.ExecuteQuery()
        }
     
        Write-host "All Term Sets Deleted Successfully from the Term Group '$TermGroupName'!" -ForegroundColor Green
    }
    else
    {
        Write-host "Term Group '$TermGroupName' Doesn't Exist!" -ForegroundColor Yellow
    } 
}
Catch {
    write-host -f Red "Error Deleting Term Sets!" $_.Exception.Message
}

PnP PowerShell เพื่อลบชุดคำใน SharePoint Online:

PnP PowerShell ทำให้ง่ายขึ้นมาก! เพียงระบุเส้นทางชุดคำสำหรับ Remove-PnPTaxonomyItem cmdlet


#Config Variable
$AdminCenterURL = "https://Crescent-admin.sharepoint.com"

#Connect to PnP Online
Connect-PnPOnline -Url $AdminCenterURL -Credentials (Get-Credential)

#Delete the Term set "regions" under "Deals Pipeline" Group
Remove-PnPTaxonomyItem "Deals Pipeline|Region" -Force

วิธีนี้จะลบชุดคำ "ภูมิภาค" ออกจากกลุ่ม "ไปป์ไลน์ข้อเสนอ"

โปรดทราบว่าการลบชุดคำจะลบข้อกำหนดทั้งหมดภายในชุดคำนั้นด้วย หากคุณต้องการเก็บข้อกำหนดไว้ คุณควรพิจารณาย้ายไปยังชุดคำอื่น ในบทความนี้ เราได้อธิบายวิธีการลบชุดคำที่ไม่จำเป็นอีกต่อไป ซึ่งจะช่วยให้คุณจัดระเบียบที่เก็บคำของคุณได้

บทความที่เกี่ยวข้อง