Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Monitor Scheduled Job Status

Reply
Thread Tools Display Modes

Monitor Scheduled Job Status

 
 
Guest
Posts: n/a

 
      07-27-2008
I'd like to create a script that sends email if Scheduled Job task has
failed. Can somebody post an example?

PowerShell script is preferred, but VBScript is fine as well.

 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a

 
      07-28-2008

<> wrote in message
news:5ED75866-7568-4FA4-86C9-...
> I'd like to create a script that sends email if Scheduled Job task has
> failed. Can somebody post an example?
>
> PowerShell script is preferred, but VBScript is fine as well.


The easiest way is probably to monitor the commands that
get executed by the scheduled job and invoke the VB Script
file below when something goes wrong:

schema = "http://schemas.microsoft.com/cdo/configuration/"
Set objEmail = CreateObject("CDO.Message")
With objEmail
.From = ""
.To = ""
.Subject = "Task Scheduler Error Report"
.Textbody = "The quick brown fox " & Chr(10) & "jumps over the lazy dog"
.AddAttachment "d:\Testfile.txt"
With .Configuration.Fields
.Item (schema & "sendusing") = 2
.Item (schema & "smtpserver") = "mail.Izorich.com"
.Item (schema & "smtpserverport") = 25
.Item (schema & "smtpauthenticate") = cdoBasic
.Item (schema & "sendusername") = ""
.Item (schema & "sendpassword") = "somepassword"
End With
.Configuration.Fields.Update
.Send
End With


 
Reply With Quote
 
Guest
Posts: n/a

 
      07-28-2008
I know how to send email from scripts. The question is how do I get WMI
event that scheduled job has failed? Or how do I monitor status of scheduled
jobs in general.

"Pegasus (MVP)" <> wrote in message
news:...
>
> <> wrote in message
> news:5ED75866-7568-4FA4-86C9-...
>> I'd like to create a script that sends email if Scheduled Job task has
>> failed. Can somebody post an example?
>>
>> PowerShell script is preferred, but VBScript is fine as well.

>
> The easiest way is probably to monitor the commands that
> get executed by the scheduled job and invoke the VB Script
> file below when something goes wrong:
>
> schema = "http://schemas.microsoft.com/cdo/configuration/"
> Set objEmail = CreateObject("CDO.Message")
> With objEmail
> .From = ""
> .To = ""
> .Subject = "Task Scheduler Error Report"
> .Textbody = "The quick brown fox " & Chr(10) & "jumps over the lazy dog"
> .AddAttachment "d:\Testfile.txt"
> With .Configuration.Fields
> .Item (schema & "sendusing") = 2
> .Item (schema & "smtpserver") = "mail.Izorich.com"
> .Item (schema & "smtpserverport") = 25
> .Item (schema & "smtpauthenticate") = cdoBasic
> .Item (schema & "sendusername") = ""
> .Item (schema & "sendpassword") = "somepassword"
> End With
> .Configuration.Fields.Update
> .Send
> End With
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fax Status Monitor Crow Windows Vista Printing / Faxing / Scanning 0 02-27-2008 09:06 PM
Monitor Scheduled Tasks Tim Kelley Windows Server 2 07-02-2007 06:16 PM
Re: Check status of a scheduled job Don Grover Scripting 1 03-25-2005 08:04 PM
Re: Scheduled NTBackup.exe Fails with Status Running Kristofer Gafvert Windows Server 0 08-13-2004 04:20 PM
Re: Scheduled NTBackup.exe Fails with Status Running Zoltan Fekete Windows Server 0 08-13-2004 03:53 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59