Retrieving job history over a period of time

$test = Get-SPWebApplication "http://2013app/"

$myStartTime = "3/01/2014 12:30:00 AM"

$myStopTime = "3/02/2014 3:30:00 AM"

#GET ALL BETWEEN THAT TIME PERIOD

Write-Host "Fetching all jobs to JobHistoryOutput.csv for $myStartTime - $myStopTime..." -ForeGroundColor Red

$test.JobHistoryEntries | Where-Object {($_.StartTime -gt $myStartTime) -and ($_.StartTime -lt $myStopTime)} | Export-Csv JobHistoryOutput.csv –NoType

Write-Host "Done! Check JobHistoryOutput.csv for info." -ForeGroundColor Green

#GET ALL THAT FAILED BETWEEN THAT TIME PERIOD

Write-Host "Fetching all errors to JobHistoryOutputErrors.csv for $myStartTime - $myStopTime..." -ForeGroundColor Red

$test.JobHistoryEntries | Where-Object {($_.StartTime -gt $myStartTime) -and ($_.StartTime -lt $myStopTime) -and ($_.Status -ne 'Succeeded')} | Export-Csv JobHistoryOutputErrors.csv –NoType

Write-Host "Done! Check JobHistoryOutputErrors.csv for info." -ForeGroundColor Green

 

 

 

Retreiving SharePoint 2010 Jobs Details by Date and Time

1. Log onto your SharePoint 2010 application server with farm admin rights.

2. Run SharePoint Admin Shell.

3. Change the SharePoint application in the script on line 2 (mine was http://2013app ). Change the dates and times in the scriptlines 3 and 4.

4. Run the script as shown below:
get-history

5. View output from the script:

get-history1
6. You’ll get two files. C:\JobHistoryOutput.csv is all jobs. C:\JobHistoryOutputErrors.csv is jobs that didn’t get a “Succeeded” status. Sort and filter in excel for the results you want: JobDefinitionId, JobDefinitionTitle, WebApplicationId, WebApplicationName, ServiceId, ServerId, ServerName, Status, StartTime, EndTime, DatabaseName, ErrorMessage