zoukankan      html  css  js  c++  java
  • Force stop and then start a full crawl on all content sources in a SharePoint 2010 farm using PowerShell(转)

    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

  • 相关阅读:
    Shell脚本最佳实践
    tmux会话断电保存自动恢复
    [JD15] 括号匹配方案
    [LeetCode 187.] 重复的DNA序列
    [LeetCode 162.] 寻找峰值
    基于 Chocolatey 打造 Windows 开发环境
    [LeetCode 71.] 简化路径 【IO】
    【栈】栈排序
    [LeetCode 829.] 连续整数求和
    [LeetCode 29.] 两数相除
  • 原文地址:https://www.cnblogs.com/love007/p/2565678.html
Copyright © 2011-2022 走看看