SharePoint 2013 Search Crawl Log History Report

Requirement: Generate SharePoint 2013 search crawl report on daily basis.

How to Get SharePoint Search Crawl Log?

Crawl history can be viewed from SharePoint 2013 search service application as in the below screen. It gives the crawl log history report for all content sources.

sharepoint 2013 crawl history

Why don’t we automate it with PowerShell, so that we’ll get crawl history report in E-mail?

PowerShell to get crawl log history in E-mail:

This PowerShell script extracts crawl history data and sends out email.

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

#Get the search service application
$SSA = Get-SPEnterpriseSearchServiceApplication #-Identity "Search Service Application Name"

#Get all content sources
$ContentSources = Get-SPEnterpriseSearchCrawlContentSource -SearchApplication $SSA #| where {$_.Name -eq $ContentSourceName}

$ReportDate = Get-Date -format "dd-MM-yyyy"

#CSS Styles for the Table
$style = "Crawl History Report: "
$style = $style + "<style>BODY{font-family: Arial; font-size: 10pt;}"
$style = $style + "TABLE{border: 1px solid black; }"
$style = $style + "TH{border: 1px solid black; background: #dddddd; padding: 5px; }"
$style = $style + "TD{border: 1px solid black; padding: 2px; }"
$style = $style + "</style>"

#Frame Email body
$EmailBody = $ContentSources | Select Name, SuccessCount, WarningCount, ErrorCount,CrawlStarted,CrawlCompleted,  @{label="CrawlDuration";expression={$_.CrawlCompleted - $_.CrawlStarted}} | ConvertTo-Html -Head $style 

#Set Email configurations

#Get outgoing Email Server
$EmailServer = (Get-SPWebApplication -IncludeCentralAdministration | Where { $_.IsAdministrationWebApplication } ) | %{$_.outboundmailserviceinstance.server} | Select Address

$From = "[email protected]"
$To = "[email protected]"
$Subject = "Crawl History Report as on: "+$ReportDate
$Body = "Hi SharePoint Team,<br /><br />Here is a Crawl History report as on $ReportDate <br /><br />" + $EmailBody

#Send Email
Send-MailMessage -smtpserver $EmailServer.Address -from $from -to $to -subject $subject -body $body -BodyAsHtml

Schedule the above script in Windows task scheduler to receive E-mail notifications on schedule basis. Here is the script in action:

sharepoint 2013 search crawl history

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!

4 thoughts on “SharePoint 2013 Search Crawl Log History Report

  • August 26, 2020 at 2:15 PM

    It’s worked well.. thank you. But, when running the script, if crawl in progress, and the “crawlcompleted” field is empty, then i am getting the crawl duration in negative values. Could you please help how to resolve this? Instead of negative values, we can set the duration like in progress or showing empty.

  • July 17, 2018 at 7:13 PM

    Hi there, this works but it only emails the recent crawl history. I want to see all history for the same day. How can I modify it?


  • December 20, 2016 at 11:50 AM

    It is a great script. Thanks for sharing. Only thing I would like to do is filter it on full crawls only. Is that possible?


Leave a Reply