Problem: SharePoint 2013 search crawl process is running infinitely!
Solution:
Tried stopping the crawl process from search administration page of SharePoint 2013 central administration, but failed.
PowerShell to rescue! This script checks whether the crawler status is "Idle" for the given content source. If not, it stops the crawl activity and wait until the status is changed to Idle.
PowerShell script to force stop SharePoint 2013 search crawl:
To stop Search crawl forcefully in SharePoint, use this script.
Solution:
Tried stopping the crawl process from search administration page of SharePoint 2013 central administration, but failed.
PowerShell to rescue! This script checks whether the crawler status is "Idle" for the given content source. If not, it stops the crawl activity and wait until the status is changed to Idle.
PowerShell script to force stop SharePoint 2013 search crawl:
To stop Search crawl forcefully in SharePoint, use this script.
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinueI used this script when the crawler stuck in the stopping state! Related post: Start SharePoint Search Crawl using PowerShell
#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 Successfylly!" -f DarkGreen
}
else
{
Write-Host "Search Crawl is not running!" -f Red
}