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

[玩转系统] 使用 PowerShell 在 SharePoint Server 中启用连续爬网

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

使用 PowerShell 在 SharePoint Server 中启用连续爬网


SharePoint 2016 中引入了连续爬网,以使搜索结果尽可能保持最新。要在 SharePoint 2013 中启用连续爬网,请按照下列步骤操作:

  • 以场管理员身份登录到 SharePoint 2013 管理中心。在管理中心中,单击“应用程序管理”选项卡下的“管理服务应用程序”
  • 单击您的搜索服务应用程序。
  • 在“搜索服务管理”页面中,单击左侧导航中的“内容源”链接。
  • 在“管理内容源”页面上,单击要启用连续爬网的 SharePoint 内容源。
  • 向下滚动并选择“抓取计划”部分下的“启用连续抓取”选项。

    [玩转系统] 使用 PowerShell 在 SharePoint Server 中启用连续爬网

  • 单击“确定”保存更改。

SharePoint 2016:使用 PowerShell 启用连续爬网

以下是用于在 SharePoint 2013 或 SharePoint 2016 中启用连续爬网的 PowerShell 脚本。


#Get Search service application
$SSA =  Get-SPEnterpriseSearchServiceApplication

#Get the content source by name
$ContentSource = Get-SPEnterpriseSearchCrawlContentSource -SearchApplication $SSA -Identity "Local SharePoint sites"

#Check if Continuous Crawls is already enabled
if($ContentSource.EnableContinuousCrawls -eq $true)
{
 Write-host "Continuous Crawl is already Enabled for this content source!" -ForegroundColor Red
}
else
{
        #enable continuous crawl sharepoint 2013
        Set-SPEnterpriseSearchCrawlContentSource -Identity $ContentSource -EnableContinuousCrawls $True
        Write-host "Enabled Continuous Crawl Successfully!" -ForegroundColor Green
}

使用 PowerShell 对所有 SharePoint 2013 内容源启用连续爬网

虽然上面的脚本为给定的内容源名称启用了连续爬网,但让我们为 SharePoint 2016 中的所有 SharePoint 内容源启用连续爬网:


#Get Search service application
$SSA =  Get-SPEnterpriseSearchServiceApplication

#Get all SharePoint content sources
$SPContentSources = Get-SPEnterpriseSearchCrawlContentSource -SearchApplication $SSA | Where-object {$_.Type -eq "SharePoint"} 

foreach ($ContentSource in $SPContentSources) 
{ 
    #Check if Continuous Crawls is already enabled
    if($ContentSource.EnableContinuousCrawls -eq $true)
    {
 Write-host "Continuous Crawl is already Enabled for $($ContentSource.Name)!" -ForegroundColor Yellow
    }
    else
    {
        #enable continuous crawl sharepoint 2013
        Set-SPEnterpriseSearchCrawlContentSource -Identity $ContentSource -EnableContinuousCrawls $True
        Write-host "Enabled Continuous Crawl Successfully for $($ContentSource.Name)" -ForegroundColor Green
    }
}

要在 SharePoint 中禁用连续爬网,请参阅:如何使用 PowerShell 在 SharePoint 2013 中禁用连续爬网?

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

取消回复欢迎 发表评论:

关灯