Getting and Analyzing Timer Job History

While troubleshooting a SharePoint 2010 outage for a customer, I had the need to determine whether any timer jobs were running for excessive amounts of time.  You can get this information via Central Administration (CA), but there are typically thousands of timer job executions during a day.  Unfortunately, CA does not provide a sorting/filtering mechanism that reduces the list to a manageable number.

At this point, it was PowerShell to the rescue.  I needed to see all timer jobs for a specific time period.  The script below will return all timer job history for a given time period, or it can be easily modified to limit the results based on any combination of timer job property.

$timerjobs = Get-SPTimerJob

$timerjobs | foreach {

(Get-SPTimerJob –Identity $_.Id).HistoryEntries | Where {$_.StartTime –ge “09/17/2012”} | Format-Table –Property StartTime,EndTime,JobDefinitionTitle


Pipe the output to a .txt file so it can be open with Excel and analyzed.  My scenario required looking through ~85,000 history items and determining if any ran for an excessive amount of time.  I opened the .txt file in Excel (fixed-width, three columns) and formatted the results as a table.  By filtering the StartTime column to only non-date values, I was able to find and delete the headings, spaces, etc. that PowerShell added to the output.  Next, I removed the filter and added a column after the "EndTime” column so that I could calculate the execution time.  I applied a custom format of “h:mm:ss” to the StartTime/EndTime columns and used the formula of “=B#-A#” in the new column to calculate the execution time (# = the Excel row number).  The final step was to sort the Excel table by the execution time column (largest to smallest) and I was quickly able to see the timer jobs that ran long.