Here is the script I used to check the status of all jobs on SQL Server Agent
[reflection.assembly]::LoadWithPartialName(“Microsoft.SqlServer.Smo”) | out-null
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$computers = get-content “DBServers.txt”
$OutFile = “DBJobLog.txt”
$Line = “Production Databases Job Status”
$Line | out-file $OutFile
foreach ($computer in $computers)
{
$Line = “r
n———————————–”
$Line | out-file $OutFile -append
$Line = “Working on “ + $computer
write-host $Line
$Server = new-object (“Microsoft.SqlServer.Management.Smo.Server”) “$computer”
$Line = “Server :” + $computer + “ (Version: “ + $Server.Information.VersionString + “)r
n———————————–”
$Line | out-file $OutFile -append
$Line = “[Jobs Status]”
$Line | out-file $OutFile -append
$Server.jobserver.Jobs | select name,IsEnabled,LastRunDate,LastRunOutcome,NextRunDate `
| Format-Table -auto | Out-File $OutFile -append
}
write-host “Output File Created: .” $Outfile
.