Now this time I would like to get the SQL Agent Job stepID from powershell. I only have the StepName and I would like to get information from the Job History as follow:
Well… I have to get it somehow!!
I have this working…
Example:
write-host “Name: $($job.JobSteps[1].Name) RunDate: $($job.JobSteps[1].LastRunDate) Status: $($job.JobSteps[1].LastRunOutCome)”
However, in my program, the user is entering the StepName only. I tried the following:
$stepID = $job.CurrentRunStep
write-host “StepID = $steID”
But it gives me the following:
StepID = 0 (unknown)
You’d have to query that from SQL Server. Sorry, I thought you had $stepID. I’m not sure how you’d query that - it’s really a SQL Server question, not PowerShell. Again, sorry.