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

[玩转系统] SharePoint 完全爬网陷入困境?使用 PowerShell 强制停止 SharePoint 搜索爬网

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

SharePoint 完全爬网陷入困境?使用 PowerShell 强制停止 SharePoint 搜索爬网


问题: SharePoint 2013 搜索爬网进程无限运行!而且爬行没有停止!

解决方案:

我尝试从 SharePoint 2013 管理中心的搜索管理页面停止爬网过程,但失败了。

[玩转系统] SharePoint 完全爬网陷入困境?使用 PowerShell 强制停止 SharePoint 搜索爬网

PowerShell 来拯救!此脚本检查给定内容源的爬网程序状态是否为“空闲”。如果没有,它将停止爬网活动并等待,直到状态更改为空闲。

停止对所有内容源的搜索抓取:

以下是如何使用 PowerShell 停止对 SharePoint 中所有内容源的搜索爬网。


#Stop the crawl for all content sources
Get-SPEnterpriseSearchCrawlContentSource -SearchApplication "Search Service Application" | ForEach-Object {  
    If($_.CrawlStatus -ne "Idle") 
    {
        Write-Host "Stopping crawl on Content source $($_.Name)..."  
        $_.StopCrawl()  

        While ($_.CrawlStatus -ne "Idle")
     {
            Write-Host "Waiting to crawl to be stopped..." -f DarkYellow
            sleep 3
        }
        write-host "Crawl Stopped Successfully!" -f DarkGreen
    }
    else
    {
        write-host "Crawl Status of the Content source '$($_.Name)' is Idle!" -f DarkGreen
    }
}

强制停止特定内容源上的 SharePoint 2013 搜索爬网的 PowerShell 脚本:

要在 SharePoint 中强制停止搜索抓取,请使用此脚本。


Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

#Content source Name
$ContentSourceName= "Crescent Portal" #default "Local SharePoint sites"
 
#Get the search service application
$SSA = Get-SPEnterpriseSearchServiceApplication #-Identity "Search Service Application Name"
 
#Get the content source
$ContentSource = $SSA | Get-SPEnterpriseSearchCrawlContentSource -Identity $ContentSourceName

#Check if Crawler is not already running
if($ContentSource.CrawlState -ne "Idle")
{
        Write-Host "Stopping Crawl..."           

        $ContentSource.StopCrawl()

        #Wait till its stopped
        while($ContentSource.CrawlState -ne "Idle")
        {
            Write-Host "Waiting to crawl to be stopped..." -f DarkYellow
            sleep 5
        }
        write-host "Crawl Stopped Successfully!" -f DarkGreen
}
else
{   
      Write-Host "Search Crawl is not running!" -f Red
}

禁用对所有 SharePoint 内容源的连续爬网


$SSA =  Get-SPEnterpriseSearchServiceApplication
$ContentSources = $SSA | Get-SPEnterpriseSearchCrawlContentSource | Where{$_.Type -eq "SharePoint"} 
foreach ($cs in $ContentSources)
{ 
  $cs.EnableContinuousCrawls = $false 
  $cs.Update() 
}
如果您仍然面临爬网停留在停止状态的麻烦,请转到服务控制台并重新启动 SharePoint Server 搜索!

我在爬虫卡在停止状态的时候就用了这个脚本!相关文章:使用 PowerShell 启动 SharePoint 搜索爬网

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

取消回复欢迎 发表评论:

关灯