I’ve got a script that reports on failed Sql Agent jobs, run nicely, except that when a Job fails, we’ll work on fixing it and usually rerun it…if it fails when we run it, I want that excluded from the report.
I want this included:
RunDate : 11/3/2018 8:01:28 AM StepID : 0 Server : server\instance JobName : ourjob StepName : (Job outcome) Message : The job failed. The Job was invoked by User domain\serviceaccount. The last step to run was step 3
But I want to exclude this:
RunDate : 11/3/2018 8:01:28 AM StepID : 0 Server : server\instance JobName : ourjob StepName : (Job outcome) Message : The job failed. The Job was invoked by User domain\user. The last step to run was step 3
I’m using this cmd:
Get-SqlAgentJobHistory -ServerInstance $SqlServer -OutcomesType Failed -StartRunDate ((Get-Date).AddMinutes(-15)) | ` Select | select RunDate,StepID,Server,JobName,StepName,Message