Thursday 13 June 2013

Configure Search Crawling with PowerShell

A note to myself really so that I can find it easily.

As part of an installation script I wanted to configure an incremental crawl schedule then start a full crawl. The following script met these needs:

$searchapp = Get-SPEnterpriseSearchServiceApplication "Search Service Application"

$contentsource = Get-SPEnterpriseSearchCrawlContentSource "Local SharePoint Sites" -SearchApplication $searchapp

$contentsource | Set-SPEnterpriseSearchCrawlContentSource -ScheduleType Incremental -DailyCrawlSchedule -CrawlScheduleRunEveryInterval 1 -CrawlScheduleRepeatInterval 170 -CrawlScheduleRepeatDuration 180 -Confirm:$false

$contentsource.StartFullCrawl()

This script was created based on the following posts so thanks the authors for pointing me in the right direction:
http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/28/how-to-use-sharepoint-2010-windows-powershell-cmdlets-to-manage-search-crawls.aspx
http://habaneroconsulting.com/en/insights/Setting-crawl-schedules-with-PowerShell.aspx#.Ubm3sfmG3LM



No comments:

Post a Comment