How to get SharePoint Timer Job History using PowerShell

This PowerShell SharePoint tutorial, we will discuss how to get the SharePoint timer job history using PowerShell as well as from SharePoint 2013/2016 central administration.

Recently, I got a requirement to retrieve and review the SharePoint timer job history for troubleshooting an issue in SharePoint 2013 farm.

Get SharePoint Timer Job History from SharePoint central administration

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

Open SharePoint central administration, Go to Monitoring -> Check Job status.

get timer job history powershell

Click on the “Job History” link from the left navigation.

sharepoint powershell get timer job history

Under the “View” filter, choose “Job Definition”. You’ll find a cascading filter appears as “Job Definition” once you choose View filter as “Job definition“. You can also choose options such as Service, Web Application, and Server.

sharepoint 2013 get timer job history powershell

Under the “View” filter, choose “Job Definition”. You’ll find a cascading filter appears as “Job Definition” once you choose View filter as “Job definition”. You can also choose options such as Service, Web Application, and Server.

sharepoint powershell get timer job history

Click on the job definition filter to “change job definition“.

sharepoint timer job history powershell

Pick the relevant timer job definition. E.g. Audit Log Trimming, Immediate Alerts, etc.

sharepoint 2016 get timer job history powershell

Now, you’ll find the job history for the selected timer job as below.

get timer job history powershell sharepoint

SharePoint PowerShell get timer job history

Now, we will check how to search and export timer job history for a particular time period using PowerShell.

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 time period other than navigating page by page. So, let’s use a PowerShell script to find and extract timer job history.

Below is the PowerShell script to get all the timer jobs of a web application in SharePoint 2013/2016.

Here, you just need to change the web application URL and then you can use the code inside Windows PowerShell ISE.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
# Variables
$WebAppURL = http://Test.contoso.com/default.aspx
$StartTime = "06/22/2016 01:00:00 AM" # mm/dd/yyyy hh:mm:ss
$EndTime = "06/24/2016 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
Get timer job history for a specific timer job:
# Variables
$StartTime = "06/26/2016 01:00:00 AM" # mm/dd/yyyy hh:mm:ss
$EndTime = "06/26/2016 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

Failed SharePoint Timer Jobs History Report using PowerShell

Below is the PowerShell script to get the failed timer jobs history report using PowerShell in SharePoint 2013/2016.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
# Variables
$WebAppURL = http://Test.contoso.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

Below screenshot:

sharepoint powershell get timer job history

And the output report:

sharepoint 2013 get timer job history powershell

You may like following SharePoint tutorials:

This SharePoint tutorial, we learned how to get SharePoint timer job history from central administration as well as by using PowerShell. We also saw, how to get the failed timer jobs history report using PowerShell in SharePoint 2013/2016.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>