Tuesday, 29 May 2012

Force stop and then start a full crawl on all content sources in a SharePoint 2010 farm using PowerShell

There have been many times where I have needed to run a full crawl of all content sources on a SharePoint 2010 farm, but I quite often there are already crawls taking place, which I prefer to stop before starting a new one.

The script below walks through each content source and does the following:

  1. Checks whether the crawl status is set to “Idle”
  2. If the content source is currently involved in a crawl activity, stop the activity and wait until the status changes back to Idle
  3. If the content source is Idle, then start a full crawl

To use, run the following script in the SharePoint Management Shell, replacing “Search Service Application” with the name of your Search service application:

Get-SPEnterpriseSearchCrawlContentSource -SearchApplication "Search Service Application" | ForEach-Object {
    if ($_.CrawlStatus -ne "Idle")
    {
        Write-Host "Stopping currently running crawl for content source $($_.Name)..."
        $_.StopCrawl()
       
        do { Start-Sleep -Seconds 1 }
        while ($_.CrawlStatus -ne "Idle")
    }
   
    Write-Host "Starting full crawl for content source $($_.Name)..."
    $_.StartFullCrawl()
}

For info, you can use the following script if you want to display the crawl status of all content sources on your farm:

Get-SPEnterpriseSearchCrawlContentSource -SearchApplication "Search Service Application" | select Name, CrawlStatus

This will give you an output similar to the following:

image

47 comments:

  1. Is there a way to force stop a crawl and keep it from resuming on schedule without modifying the schedule itself?

    ReplyDelete
    Replies
    1. You could stop the crawl and then pause the content source, either from Central Admin or by using the PauseCrawl() method in the same way as I have used StopCrawl() above

      Delete
  2. What is the "select name" supposed to be? I have tried the web URL and the Local SharePoint sites and get an error. The search will not stop/ It ha been going for 86 hours!

    ReplyDelete
    Replies
    1. Select name only displays the name of the content source in the PowerShell console. If you really are unable to stop a crawl then you may need to reset the search index, which can be done in Central Admin or by using the script in this article: http://get-spscripts.com/2012/02/resetting-sharepoint-2010-search-index.html

      Delete
  3. Hi,

    In SharePoint 2013 I couldn't stop the Continous Crawl using PowerShell.

    Could you please guide me.

    Thank you

    Sri

    ReplyDelete
    Replies
    1. Same. From what i could gather so far there is no way to do this from powershell. This must be the only thing u can do from the interface but not from powershell.

      Anyone found a way to do it without using the interface?

      Delete
    2. May be it is crazy idea and I do not know whether that will work or not. Anyway is it possible change crawl settings fron continuous to incremental then stop the crawl do something after that. Again switch back to continuous from incremental?

      Is anyone

      Delete
    3. Here's some code to stop the Continuous Crawl

      $SearchApp = "Search Service Application name "
      $IntranetCS = "Content Source Name"
      $ContentSource = Get-SPEnterpriseSearchCrawlContentSource -SearchApplication $SearchApp -Identity $IntranetCS
      $ContentSource.EnableContinuousCrawls = $false
      $ContentSource.Update()

      Delete
  4. sharepoint crawl is running but not stopping. This is happening after we replaced the old SAN storage. Please suggest how to resolve this issue. We stopped few times and tried. No success.

    ReplyDelete
  5. Congratulations, your blog is appealing and informative. Going through your Information, I found quite a few new ideas to implement

    ReplyDelete
  6. I gone through your article It was good keep updating new topics
    SharePoint Online Training

    ReplyDelete
  7. great doing. and i happy to visit your blog to know about this wonderful information. thanks for sharing. keep updating.
    Sharepoint Training in chennai

    ReplyDelete
  8. This is really awesome. Full of knowledge and latest information about web design.Gorilla Online Marketing

    ReplyDelete
  9. The war between humans, orcs and elves continues earn to die . Lead your race through a series of epic battles, using your crossbow to fend off foes and sending out units to destroy castleshappy wheels . Researching and upgrading wisely will be crucial to your success! There are 5 ages total and each one will bring you new units to train to fight in the war for you cause.
    earn to die 2
    Whatever you do, don’t neglect your home base because you cannot repair it and once it is destroyed, you lose! Age of War is the first game of the series and really sets the tone for the Age of War games . Also try out the Age of Defense series as it is pretty similar.
    In this game, you start at the cavern men’s age, then evolvetank trouble ! There is a total of 5 ages, each with its units and turrets. Take control of 16 different units and 15 different turrets to defend your base and destroy your enemy.
    The goal of the game also differs depending on the level. In most levels the goal is to reach a finish line or to collect tokens. Many levels feature alternate or nonexistent goals for the player. The game controls are shown just under gold miner. Movement mechanisms primarily include acceleration and tilting controls. cubefield
    It consists of a total of 17 levels and the challenge you face in each level increases as you go up. unfair mario The game basically has a red ball that has to be moved across the various obstacles in its path to the goal. slitherio

    ReplyDelete
  10. A good blog. Thanks for sharing the information. It is very useful for my future. keep sharing
    red ball 2 | duck life 2 | happy wheels | Red Ball | Red ball 3 | Flash Games| Tank trouble

    ReplyDelete
  11. Wonderful blog! I found it while searching on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Many thanks.
    2048 game | five nights at freddy's 4 | plants vs zombies | five nights at freddy's 3 | fireboy and watergirl | fireboy and watergirl 4||red ball

    ReplyDelete
  12. Nice website, the site is very interesting, a lot of helpful articles and the latest news that arouse interest. nice!!
    obat penghilang kista coklat tradisional
    obat penghilang polip hidung tradisional
    obat penghilang gondongan tradisional

    ReplyDelete
  13. I still liked this article, good, good content, and unique design.Thank you for sharing the article.
    Obat Lutut Bengkak Herbal, 100% Ampuh Mengobati Lutut Membengkak Dan Meradang

    ReplyDelete
  14. By the way, Thank you for sharing with us, and we sincerely hope you will continue to update or post other articles.
    cara menyembuhkan kram usus

    ReplyDelete
  15. [url=http://www.yeezyboost-350.us.com][b]adidas yeezy boost 350[/b][/url]
    [url=http://www.coachfactory-outletonlines.us.com][b]coach outlet online[/b][/url]
    [url=http://www.moncler-outlet.us.com][b]moncler jackets[/b][/url]
    [url=http://www.adadasstansmith.com][b]stan smith adidas[/b][/url]
    [url=http://www.adidastrainersuk.org.uk][b]adidas uk[/b][/url]
    [url=http://www.tomsshoesoutlet.in.net][b]toms outlet[/b][/url]
    [url=http://www.pandoracharmssaleclearance.me.uk][b]pandora charms sale clearance[/b][/url]
    [url=http://www.michaelkorsoutletclearance.com.co][b]michael kors outlet clearance[/b][/url]
    [url=http://www.coachoutletstore-online.us.com][b]coach outlet store online[/b][/url]
    [url=http://www.abercrombieandfitch.in.net][b]bercrombie[/b][/url]
    0323shizhong

    ReplyDelete
  16. a given article is very interesting and very useful for me, thank you very much admin and pardon me permission to share the article here :

    Obat kanker hati stadium 3
    Cara mengobati radang telinga
    Cara mengobati batuk berdarah

    ReplyDelete
  17. This is one of the cult game now, a lot of people enjoy playing them . Also you can refer to the game :
    animal jam 2 | five nights at freddys 2 | hotmail login

    ReplyDelete
  18. شركة قمة الدقة للخدمات المنزلية جوده واقل اسعار مع ضمان الخدمه بالاضافة الى الخبرة فى مجال التنظيف بالجبيل وهذا ما يميزنا شركة تنظيف مجالس بالجبيلمن اهم الشركات المتواجده فى الاسواق فنحن متخصصين فى خدمات التنظيف بشكل عام ونهدف الى شركة قمة الدقةلتنظيف منازل بالجبيل بتوفير خدمات تنظيف المنزل المختلفة , ويمكنك التعرف على أهم أعمالنا في تنظيف المنازل وهي شركة تنظيف موكيت بالجبيل تعمل الشركة جاهدة علي توفير العمالة المميزة التي تساعد في انجاز جميع المهام
    شركة قمة الدقة للتنظيف تقدم كافة اعمال تنظيف المنازل والبيوت والشقق والفلل والمجالس والمسابح باعلي جودة ممكنة وارخص الاسعار شركة تنظيف كنب بالجبيل الجميع يعانون من عدم النظافه , بالرغم من انهم يقومون بأعمال التنظيف ولكن يتعبون جدا
    شركة قمة الدقة للنظافة لكثير من الاعتبارات اهمها الدقة فى التنفيذ الترتيب واعادة شركة تنظيف سجاد بالجبيل أن لديها فريق عمل متكامل من العاملين والعاملات الذين يقومون بتنظيف كل المنازل و كل البيوت و كل الأماكن التي تحتاج إلى تنظيف فان خبره.
    شركة قمة الدقة للخدمات المنزلية أصبح التنظيف متعة وتحقيقه امرا سهلا ومتاح فاذا كنت تنزعج من ضيق الوقت أو عدم قدرتك على التنظيف أو حتى إذا كنت شركة تنظيف مساجد بالجبيل تعتبر النظافة بالنسبة للانسان من اهم عوامل الحياة الصحية

    ReplyDelete