รายงานการใช้งานคอลัมน์ Metadata ที่มีการจัดการใน SharePoint โดยใช้ PowerShell
ข้อกำหนด: ค้นหาการใช้งานคอลัมน์ Metadata ที่มีการจัดการทั้งหมดในสภาพแวดล้อมของ SharePoint
PowerShell เพื่อค้นหาการใช้งานคอลัมน์ข้อมูลเมตาที่ได้รับการจัดการ:
นี่คือสคริปต์ PowerShell เพื่อค้นหาคอลัมน์ Metadata ที่มีการจัดการทั้งหมดในไซต์คอลเลกชัน SharePoint
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$SiteCollURL="https://portal.crescent.com"
$ReportOutput="c:\MMS-Columns.csv"
$WebsColl = (Get-SPSite $SiteCollURL).AllWebs
#Array to hold Results
$ResultColl = @()
#Loop through each site, List and Fields
Foreach($web in $WebsColl)
{
Write-host "Scanning Web:"$Web.URL
Foreach($list in $web.Lists)
{
Foreach($Field in $list.Fields)
{
if($field.GetType().Name -eq "TaxonomyField")
{
$Result = New-Object PSObject
$Result | Add-Member -type NoteProperty -name "List Name" -value $List.Title
$Result | Add-Member -type NoteProperty -name "URL" -value "$($List.ParentWeb.Url)/$($List.RootFolder.Url)"
$Result | Add-Member -type NoteProperty -name "Field Name" -value $Field.Title
$ResultColl += $Result
}
}
}
}
#Export Results to a CSV File
$ResultColl | Export-csv $ReportOutput -notypeinformation
Write-Host "Managed Metadata columns usage Report has been Generated!" -f Green
สคริปต์นี้จะสแกนแต่ละรายการของไซต์คอลเลกชันที่กำหนดและสร้างรายงานในรูปแบบ CSV
PowerShell เพื่อค้นหาข้อกำหนด Metadata ที่มีการจัดการทั้งหมดที่ใช้งานอยู่:
ตอนนี้ส่วนถัดไป รับคำศัพท์ใดบ้างที่ใช้ในคอลัมน์ MMS เหล่านี้ ค่านิยมของพวกเขา:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$SiteCollURL="https://portal.crescent.com"
$ReportOutput="c:\MMS-Terms-Usage.csv"
$WebsColl = (Get-SPSite $SiteCollURL).AllWebs
#Array to hold Results
$ResultColl = @()
#Loop through each site, List and Fields
Foreach($web in $WebsColl)
{
Write-host "Scanning Web:"$Web.URL
Foreach($list in $web.Lists)
{
#Get all Managed metadata fields
Foreach($Field in $list.Fields | where {$_.GetType().Name -eq "TaxonomyField"})
{
Foreach ($item in $list.Items)
{
#Get All values of MMS field
$MMSFieldValueColl = $item[$Field.Title] #-as [Microsoft.SharePoint.Taxonomy.TaxonomyFieldValueCollection]
#concatenate each term in the collection
$MMSFieldTerms=[string]::Empty
Foreach ($MMSFieldValue in $MMSFieldValueColl)
{
if($MMSFieldValue.label -ne $null)
{
$MMSFieldTerms+=$MMSFieldValue.label+";"
}
}
#Collect the result
if($MMSFieldTerms -ne '')
{
$Result = New-Object PSObject
$Result | Add-Member -type NoteProperty -name "MMs Column Name" -value $Field.Title
$Result | Add-Member -type NoteProperty -name "MMS Column Value" -value $MMSFieldTerms
#Get the URL of the Item
$ItemURL= $Item.ParentList.ParentWeb.Site.MakeFullUrl($item.ParentList.DefaultDisplayFormUrl)
$ItemURL=$ItemURL+"?ID=$($Item.ID)"
$Result | Add-Member -type NoteProperty -name "Item URL" -value $ItemURL
$Result | Add-Member -type NoteProperty -name "List Name" -value $List.Title
$Result | Add-Member -type NoteProperty -name "List URL" -value "$($List.ParentWeb.Url)/$($List.RootFolder.Url)"
$ResultColl += $Result
}
}
}
}
}
#Export Results to a CSV File
$ResultColl | Export-csv $ReportOutput -notypeinformation
Write-Host "Managed Metadata columns usage Report has been Generated!" -f Green
