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

[玩转系统] 使用 PowerShell 在 SharePoint 搜索中添加新内容源

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

使用 PowerShell 在 SharePoint 搜索中添加新内容源


要求:在 SharePoint 2013/2016 中创建新的搜索内容源。

用于添加新内容源的 PowerShell 脚本:

以下是用于在 SharePoint 搜索中创建新内容源的 PowerShell 脚本。


Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

#Variables for new content source creation
$ContentSourceName= "Intranet Portal" #default "Local SharePoint sites"
$ContentSourceType="SharePoint"
$ContnetSourceURL="https://portal.crescent.com"

#Get the search service application
$SSA = Get-SPEnterpriseSearchServiceApplication #-Identity "Search Service Application Name"

#Check if the given content source Name exits already
$ContentSource = Get-SPEnterpriseSearchCrawlContentSource -SearchApplication $SSA | where {$_.Name -eq $ContentSourceName}
if ($ContentSource)
{
    write-host "Content Source Name already exist!" -f Red
    exit
}
 
#Create new content source
$ContentSource = New-SPEnterpriseSearchCrawlContentSource -SearchApplication $SSA -Type $ContentSourceType `
          -name $ContentSourceName -StartAddresses $ContnetSourceURL -MaxSiteEnumerationDepth 0

write-host "New Content Source has been created!" -f Green

#To delete a content source, use: 
#Remove-SPEnterpriseSearchCrawlContentSource -SearchApplication $SSA -Identity $ContentSourceNames
您必须对创建的任何新内容源运行完整爬网。操作方法如下:如何使用 PowerShell 启动 SharePoint 搜索爬网

Technet 中的 New-SPEnterpriseSearchCrawlContentSource 参考。

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

取消回复欢迎 发表评论:

关灯