Job.EnumHistory Method
SQL Server 2012
Enumerates a list of execution history associated with the referenced job.
Namespace: Microsoft.SqlServer.Management.Smo.Agent
Assembly: Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)
The following code example creates a job then displays its execution history.
C#
Server srv = new Server("(local)");
Job jb = srv.JobServer.Jobs["Test Job"];
DataTable jobHistory = jb.EnumHistory();
PowerShell
$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
$jb = $srv.JobServer.Jobs["Test Job"]
$jobHistory = $jb.EnumHistory()