We have a setup where SharePoint 2010 crawls several file share locations. After the crawls, we have ended up with thousands of errors. What I want to do is to export all these errors preferably to Excel instead of having to page through hundreds of pages on Central Admin.
I specifically want to export error messages for a particular content source. Is there an easy way to achieve this with PowerShell?
Edit:
I used a PowerShell script that exports all error messages as follows, but I can't figure out how to export only error messages pertaining to just one Content Source amongst all the different content sources in my Search Application:
$ssa = Get-SPEnterpriseSearchServiceApplication | Where-Object
{$_.Name -eq "Search Service Application"}
$logViewer = New-Object Microsoft.Office.Server.Search.Administration.Logviewer $ssa
$ErrorList = $logViewer.GetAllStatusMessages() | Select ErrorId
Foreach ($errorId in $ErrorList)
{
If ($errorId.errorId -eq 0 -or $errorId.errorId -eq 1)
{
}
else
{
$crawlLogFilters = New-Object
Microsoft.Office.Server.Search.Administration.CrawlLogFilters
$crawlLogFilters.AddFilter(“MessageId”, $errorId.errorId)
"Processing Error Code : " + $errorId.errorId
$startNum = 0
$errorItems += $logViewer.GetCurrentCrawlLogData
($crawlLogFilters, ([ref] $startNum))
Write-Host "Processing $startNum"
WHILE($startNum -ne -1)
{
$crawlLogFilters.AddFilter(“StartAt”, $startNum);$startNum = 0;$errorItems +=
$logViewer.GetCurrentCrawlLogData($crawlLogFilters, ([ref] $startNum));Write-Host
"Processing $startNum";
}
}
}
$errorItems | Export-CSV crawllog.csv