Checking multiple scheduled jobs status on multiple servers.

I got tired of not knowing the status of several scheduled jobs scattered across multiple servers. This script resolves that by checking the last run status of each job I define in the input file and sending me an alert if something went wrong.

After struggeling a while trying to find a way to read the last status of a job I ended up using schtasks.exe in the script, it turned out that I could not retrieve the last status code for a job created using the scheduled tasks wizard using WMI. The script is pretty basic, it uses an input file, a regular txt file, where I list the servername and then the jobname in the following format.

servername,jobname

I create an output file just because it might be handy if the e-mail somehow gets lost on the way. I then run a foreach to process every line in the provided txt file and if the jobstatus is anything other than ”0” I ouput that to a file and send an e-mail with a customized message containing the server name, the job name and the last status code.

Without further delay..here is the script.

 

 

You may also like...