Get SharePoint Timer Job History using PowerShell

Requirement: Retrieve and review the SharePoint timer job history for troubleshooting an issue.

How to get timer job history in SharePoint?

SharePoint 2013 Central Administration site provides an interface to get a timer job history. Here are the steps to get the SharePoint timer job history in SharePoint.

  • Navigate to SharePoint 2013 Central Administration site
  • Go to Monitoring >> Check Job statussharepoint 2013 get timer job history powershell
  • Click on the “Job History” link from the left navigation
    sharepoint 2013 timer job history powershell
  • Under the “View” filter, choose “Job Definition”. You’ll find an cascading filter appears as “Job Definition” once you choose View filter as “Job definition”. You can also choose options such as: Service, Web Application, Server.sharepoint timer job history powershell
  • Click on the job definition filter to “change job definition”
    sharepoint powershell get timer job history
  • Pick the relevant timer job definition. E.g. Audit Log Trimming, Immediate Alerts, etc.
    sharepoint 2013 get timer job history powershell
  • Now, you’ll find the jobs history for the selected timer job as below.
    sharepoint 2013 export timer job history

PowerShell to search and export timer job history for a particular time period:

Why PowerShell? Well, the above central admin page provides the interface to analyze timer jobs associated with a particular job or service, but there isn’t any easy way to get timer job history for a specific period other than navigating page by page. So, let’s use the PowerShell script to find and extract the timer job history.

Get all timer jobs of a web application:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
# Variables
$WebAppURL = "https://intranet.crescent.com" 
$StartTime = "09/26/2015 01:00:00 AM"  # mm/dd/yyyy hh:mm:ss
$EndTime = "09/26/2015 01:30:00 AM"

#Get all timer jobs associated with a web application
$WebApp = Get-SPWebApplication $WebAppURL

$Results = $WebApp.JobHistoryEntries | 
      where { ($_.StartTime -ge  $StartTime) -and ($_.EndTime -le $EndTime) } | 
          Select JobDefinitionTitle,WebApplicationName,ServerName,Status,StartTime,EndTime

#Send results to Grid view    
$Results | Out-GridView

SharePoint PowerShell get timer job history: Get timer job history for a specific timer job

# Variables
$StartTime = "09/26/2015 01:00:00 AM"  # mm/dd/yyyy hh:mm:ss
$EndTime = "09/26/2015 01:30:00 AM"
$TimerJobName = "Immediate Alerts"

#To Get Yesterday's use:
#$StartDateTime = (Get-Date).AddDays(-1).ToString('MM-dd-yyyy') + " 00:00:00" 
#$EndDateTime   = (Get-Date).AddDays(-1).ToString('MM-dd-yyyy') + " 23:59:59"

#Get the specific Timer job
$Timerjob = Get-SPTimerJob | where { $_.DisplayName -eq $TimerJobName } 

#Get all timer job history from the web application
$Results = $Timerjob.HistoryEntries  | 
      where { ($_.StartTime -ge  $StartTime) -and ($_.EndTime -le $EndTime) } | 
          Select WebApplicationName,ServerName,Status,StartTime,EndTime

#Send results to Grid view    
$Results | Out-GridView

SharePoint timer job history using PowerShell: Failed Timer Jobs History Report

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
# Variables
$WebAppURL = "https://intranet.crescent.com" 
$StartTime = "01/01/2016 01:00:00 AM"  # mm/dd/yyyy hh:mm:ss
$EndTime = "05/01/2016 01:30:00 AM"
$OutPutFile="D:\FailedJobHistoryRpt.csv"

#Get all timer jobs associated with a web application
$WebApp = Get-SPWebApplication $WebAppURL

#Get all Failed Timer jobs in between given Time
$Results = $WebApp.JobHistoryEntries | Where {($_.StartTime -ge $StartTime) -and ($_.EndTime -le $EndTime) -and ($_.Status -ne 'Succeeded')} 

#Export to CSV
$Results | Export-Csv $OutPutFile -NoType

write-host "Failed Timer jobs history Exported to CSV!" -F Green

and the output report:

sharepoint timer job history powershell

This CSV gives you a speedy way to analyze timer job history.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

2 thoughts on “Get SharePoint Timer Job History using PowerShell

  • This is excellent! helped us a lot. Thanks!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *