ARTICLE

Configure a Crawl Schedule for Enterprise Search Content Source in SharePoint 2010 using powershell

Posted by Vijai Anand Articles | SharePoint 2010 January 26, 2011
In this article we will be seeing how to configure a crawl schedule for enterprise search content source in SharePoint 2010 using C#.
Reader Level:

In this article we will be seeing how to configure a crawl schedule for enterprise search content source in SharePoint 2010 using C#.

In the Search service application, you can schedule a full or incremental crawl of a content source. There are four types of Schedules:

  • DailySchedule - Used to specify the number of days between crawls.
  • WeeklySchedule - Used to specify the number of weeks between crawls.
  • MonthlyDateSchedule - Used to specify the days of the month and months of the year when the crawl should occur.
  • MonthlyDayOfWeekSchedule - Used to specify the days of the month, the weeks of the month, and the months of the year when the crawl should occur.

Through UI:

  • Go to Central Administration => Application Management => Manage service applications => Search Service Application.
  • In the Navigation go to Crawling => Content Sources.
  • You could be able to see the content sources.
  • I am going to edit the content source "Local SharePoint sites" and schedule the crawl.
  • Go to ECB menu of Local SharePoint Sites =>Edit.

    Fig1.gif
     
  • You could see "Crawl schedule section" where you could schedule the Full Crawl and Incremental Crawl.

    Fig2.gif

     

Powershell script:

  • Open SharePoint 2010 Management Shell as an administrator.
  • Run the following script.

    $ssaName="Search Service Application"
    $context=[Microsoft.Office.Server.Search.Administration.SearchContext]::GetContext($ssaName)


    $daily=New-Object Microsoft.Office.Server.Search.Administration.DailySchedule($context)
    $daily.BeginDay="25"
    $daily.BeginMonth = "1"
    $daily.BeginYear = "2010"
    $daily.StartHour = "2"
    $daily.StartMinute = "30"
    $daily.DaysInterval = "1"


    $weekly=New-Object Microsoft.Office.Server.Search.Administration.WeeklySchedule($context)
    $weekly.BeginDay="25"
    $weekly.BeginMonth = "1"
    $weekly.BeginYear = "2010"
    $weekly.StartHour = "23"
    $weekly.StartMinute = "15"
    $weekly.WeeksInterval = "1"


    $contentsource = Get-SPEnterpriseSearchCrawlContentSource -SearchApplication $ssaName -Identity "Local SharePoint Sites"

    $contentsource.IncrementalCrawlSchedule=$daily
    $contentsource.FullCrawlSchedule=$weekly
    $contentsource.Update()

     
  • You could see the Full Crawl and Incremental Crawl has been scheduled successfully which is also reflected in the UI.

    Fig3.gif

 

Login to add your contents and source code to this article
post comment
     
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Get Career Advice from Experts
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.