Export SharePoint 2007 Search Crawl History using PowerShell

Here is the PowerShell script to export Search crawl history in SharePoint 2007 using PowerShell:

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.Search")

function global:Get-CrawlHistory($url)
{
	#Objects to get Crawl History
	$site = new-Object Microsoft.SharePoint.SPSite($url);
	$context = [Microsoft.Office.Server.Search.Administration.SearchContext]::GetContext($site);
	$history = new-Object Microsoft.Office.Server.Search.Administration.CrawlHistory($context);

	Write-OutPut $history.GetCrawlHistory()

	#Dispose site object
	$site.Dispose()
}

#Call the function to get Crawl History
Get-CrawlHistory -url "http://sharepoint.crescent.com" | Export-CSV "d:\Reports\CrawlLog.csv"

This gives data such as: CrawlType (2 – Increment, 1- FULL), ContentSourceID ( 4 – Local Crawls, 10 -People search), Status, Start Time, End Time, Success Count, Error Count, Warning Count of last 8 crawls.

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply