สร้างฮับประเภทเนื้อหาใน SharePoint โดยใช้ PowerShell
ฮับชนิดเนื้อหาใน SharePoint เป็นตำแหน่งที่ตั้งส่วนกลางในการจัดการชนิดเนื้อหา เว็บแอปพลิเคชันใดๆ ที่สมัครเป็นสมาชิกฮับประเภทเนื้อหาสามารถใช้ประเภทเนื้อหาจากร้านค้านี้ได้ การสร้างฮับประเภทเนื้อหาใน SharePoint โดยใช้ UI เว็บการดูแลจากศูนย์กลางมีอธิบายไว้ในบทความอื่น: วิธีสร้างฮับประเภทเนื้อหาใน SharePoint 2013 ในตอนนี้ เรามาสร้างฮับประเภทเนื้อหาใน SharePoint 2013 โดยใช้ PowerShell กันดีกว่า
สคริปต์ PowerShell เพื่อสร้างฮับประเภทเนื้อหาใน SharePoint:
การสร้างฮับชนิดเนื้อหาใน SharePoint เกี่ยวข้องกับสามขั้นตอน:
- สร้างเส้นทางที่มีการจัดการที่ชัดเจนสำหรับฮับประเภทเนื้อหา (ไม่บังคับ)
- สร้างไซต์คอลเลกชันระดับบนสุดสำหรับฮับชนิดเนื้อหา
- เปิดใช้งานคุณสมบัติการรวมฮับประเภทเนื้อหา
- ตั้งค่า URL ฮับประเภทเนื้อหาในแอปพลิเคชันบริการ MMS
นี่คือสคริปต์สำหรับสร้างฮับประเภทเนื้อหาใน SharePoint 2013 โดยใช้ PowerShell:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Configuration Parameters
$WebAppURL="https://intranet.crescent.com"
$ManagedPath="CTypeHub"
$HubOwner="Crescent\SPAdmin"
$WebApp = Get-SPWebApplication $WebAppURL
### Step 1: Create Managed Path ###
#Check if the managed path exist already
$ManagedPathExists = Get-SPManagedPath -WebApplication $WebAppURL -Identity $ManagedPath -ErrorAction SilentlyContinue
if ($ManagedPathExists -eq $null)
{
#Go ahead and create the managed path
$CTypeHubPath=New-SPManagedPath -RelativeURL $ManagedPath -WebApplication $WebAppURL -Explicit
Write-host "Managed Path Created!" -f Green
}
else
{
Write-Host "Managed path $ManagedPath already exists!" -f Yellow
}
### Step 2: Create Site Collection for Content type hub ###
#Check if ContentType hub site already exists
$CTypeHubURL = $WebAppURL+"/"+$ManagedPath
$CTypeHubExists = Get-SPSite $CTypeHubURL -ErrorAction SilentlyContinue
if($CTypeHubExists -eq $null)
{
#Create site collection
$CTypeHub = New-SPSite -Url $CTypeHubURL -Template 'STS#0' -OwnerAlias $HubOwner -Name "Content Type hub"
}
else
{
Write-Host "Content Type Hub Site $CTypeHubURL already exists!" -f Yellow
}
### Step 3: Activate Content Type hub feature ###
#Check if ContentType hub feature is already enabled
$Feature = Get-SPFeature -site $CTypeHubURL -Identity "ContentTypeHub" -ErrorAction SilentlyContinue
If($Feature -eq $null)
{
#Activate feature
Enable-SPFeature -Identity "ContentTypeHub" -url $CTypeHubURL -Force -ErrorAction SilentlyContinue
Write-Host "Activated Content Type hub feature" -F Green
}
else
{
write-host "Content Type Hub Feature already enabled!" -F Yellow
}
### Step 4: Set Content Type Hub URL in MMS Service App
#Set the Content Type Hub URL in MMS Application
$MMS = Get-SPServiceApplication | Where-Object {$_.TypeName -eq "Managed Metadata Service"}
Set-SPMetadataServiceApplication -Identity $MMS -HubUri $CTypeHubURL
#Update the Managed Metadata Service Proxy to consume from the content type hub
$MMSProxy = Get-SPServiceApplicationProxy | Where-Object {$_.TypeName -eq "Managed Metadata Service Connection"}
Set-SPMetadataServiceApplicationProxy -Identity $MMSProxy -ContentTypeSyndicationEnabled -ContentTypePushdownEnabled
นี่คืออีกโพสต์เกี่ยวกับการเปลี่ยน URL ฮับประเภทเนื้อหาในแอปพลิเคชันบริการ Metadata ที่มีการจัดการ: เปลี่ยนฮับประเภทเนื้อหาในการจัดการแอปพลิเคชันบริการ Metadata โดยใช้ PowerShell