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

[玩转系统] 使用 PowerShell 在 SharePoint 中创建内容类型中心

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

使用 PowerShell 在 SharePoint 中创建内容类型中心


SharePoint 中的内容类型中心是管理内容类型的中心位置。订阅内容类型中心的任何 Web 应用程序都可以使用此商店中的内容类型。另一篇文章介绍了使用管理中心 Web UI 在 SharePoint 中创建内容类型中心:如何在 SharePoint 2013 中创建内容类型中心? 现在让我们使用 PowerShell 在 SharePoint 2013 中创建内容类型中心。

用于在 SharePoint 中创建内容类型中心的 PowerShell 脚本:

在 SharePoint 中创建内容类型中心涉及三个步骤:

  1. 为内容类型中心创建显式托管路径(可选)
  2. 为内容类型中心创建顶级网站集
  3. 激活内容类型中心联合功能
  4. 在 MMS 服务应用程序中设置内容类型中心 URL

以下是使用 PowerShell 在 SharePoint 2013 中创建内容类型中心的脚本:


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 的另一篇文章:使用 PowerShell 在管理元数据服务应用程序中更改内容类型中心

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

取消回复欢迎 发表评论:

关灯