Hi,
When I came across the article at MSDN How to: Programmatically Export the Crawl History to a CSV File I thought I would never create such a tool just for that specific feature, as you end up with additional requirements in order to create an admin tool.
But today I needed to get data from crawl history, and I didn't want to get them from SQL (remember it is not supported ;)), so I started to write down a simple powershell script to do it. And then I realized that for this atomic actions, indeed it is a great options!: you give admin people multiple commands that they can use/combine to monitor/get information about the environment (and yes many, many things more)
## SharePoint Reference[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Administration") [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.Search.Administration") [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.Search") [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server") function global:Get-CrawlHistory($url){ trap [Exception] { write-error $("ERROR: " + $_.Exception.GetType().FullName); write-error $("ERROR: " + $_.Exception.Message); continue; } $s = new-Object Microsoft.SharePoint.SPSite($url); $c = [Microsoft.Office.Server.Search.Administration.SearchContext]::GetContext($s); $h = new-Object Microsoft.Office.Server.Search.Administration.CrawlHistory($c); Write-OutPut $h.GetCrawlHistory(); $s.Dispose();}
## SharePoint Reference[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Administration") [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.Search.Administration") [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.Search") [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server")
function global:Get-CrawlHistory($url){ trap [Exception] { write-error $("ERROR: " + $_.Exception.GetType().FullName); write-error $("ERROR: " + $_.Exception.Message); continue; }
$s = new-Object Microsoft.SharePoint.SPSite($url); $c = [Microsoft.Office.Server.Search.Administration.SearchContext]::GetContext($s); $h = new-Object Microsoft.Office.Server.Search.Administration.CrawlHistory($c);
Write-OutPut $h.GetCrawlHistory();
$s.Dispose();}
Then you can just execute: Get-CrawlHistory -url http://your_site_url/ | Export-Csv your_path_and_file_name
Then you can import to excel and make some charts.
In order to filter the information some useful columns should be denormalized: CrawlType, ContentSourceID, Status.
Cheers!
PingBack from http://www.anith.com/?p=24938
Hi, If you have read my previous post you may think, why did you stop there? Well, that is what I thought
Hi, When I was working to get powershell scripts from MSDN samples to get/set information, I created
what are minimal MOSS rights required for executing this code?
Hi There,
Thanks for the sample. FYI, I tried but the CSV file is 0KB. Not sure what I miss or the requiremnt not met. Can you advice?
This code only works for Sharepoint 2007. Has anyone been able to get crawl logs for Sharepoint 2010?