Job.EnumJobStepsByID Method ()


Returns an array of JobStep objects that belong to the referenced job and that are ordered by ID value.

Namespace:   Microsoft.SqlServer.Management.Smo.Agent
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

public JobStep[] EnumJobStepsByID()

Return Value

Type: Microsoft.SqlServer.Management.Smo.Agent.JobStep[]

A JobStep object array that represents all the job steps that belong to the referenced job. The JobStep objects are ordered by ID value.

The following code example creates a job then displays the job steps ordered by ID.


Server srv = new Server("(local)");
Job jb = new Job(srv.JobServer, "Test Job");
JobStep jbstp = new JobStep(jb, "Test Job Step");
jbstp.OnSuccessAction = StepCompletionAction.QuitWithSuccess;
jbstp.OnFailAction = StepCompletionAction.QuitWithFailure;
JobStep[] jobStepsbyID = jb.EnumJobStepsByID();


$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
$jb = new-object Microsoft.SqlServer.Management.Smo.Agent.Job($srv.JobServer, "Test Job")
$jbstp = new-object Microsoft.SqlServer.Management.Smo.Agent.JobStep($jb, "Test Job Step")
$jbstp.OnSuccessAction = [Microsoft.SqlServer.Management.Smo.Agent.StepCompletionAction]::QuitWithSuccess
$jbstp.OnFailAction = [Microsoft.SqlServer.Management.Smo.Agent.StepCompletionAction]::QuitWithFailure
$jobStepsbyID = $jb.EnumJobStepsByID()
Return to top