When SharePoint search stops everything: Stopping SharePoint Search using PowerShell

One of our SharePoint servers wasn’t responding the other day. At all. Central Administration and the sites hosted on the server wouldn’t load. You could try to login through Remote Desktop, but that would go as far as getting your login information and stop there. Ditto with the console.

Rebooting the server seemed to help slightly, in that you could actually get some stuff to load within the first 5 minutes before everything ground to a halt again. Browsing through the ULS logs showed that something was accessing content on the server under the search crawl account.

Seems like a “Full” crawl started previously never finished. But how would you stop that search without access to the Search Service Administration page?

Luckily we were able to launch a SharePoint PowerShell window before everything ground to a halt. Via http://www.sharepointdiary.com/2015/05/force-stop-sharepoint-search-crawl-using-powershell.html, the following command will let you stop SharePoint crawls using PowerShell:


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
}
}

Leave a Reply