To implement the script you need to save it as a VBS file and call using your scheduler. Here's what the script looks like.
strComputer = "."
Set objWMIService = GetObject("winmgmts:{(Security)}\\" & _
strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("Select * from __InstanceCreationEvent Where " _
& "TargetInstance ISA 'Win32_NTLogEvent'" _
& "and TargetInstance.EventCode <> '17401'" _
& "and TargetInstance.EventCode <> '17896'" _
& "and TargetInstance.EventCode <> '3198'" _
& "and TargetInstance.EventCode <> '3408'" _
& "and TargetInstance.EventCode <> '576'" _
& "and TargetInstance.EventCode <> '680'" _
& "and TargetInstance.EventCode <> '540'" _
& "and TargetInstance.EventCode <> '12517'" _
& "and TargetInstance.EventCode <> '12503'" _
& "and TargetInstance.EventCode <> '7036'" _
& "and TargetInstance.EventCode <> '17137'" _
& "and TargetInstance.EventCode <> '8128'" _
& "and TargetInstance.EventCode <> '2803'" _
& "and TargetInstance.EventCode <> '7040'" _
& "and TargetInstance.EventCode <> '552'" _
& "and TargetInstance.EventCode <> '538'" _
& "and TargetInstance.EventCode <> '1111'" _
& "and TargetInstance.EventCode <> '9'" _
& "and TargetInstance.EventCode <> '3197'" _
& "and TargetInstance.EventCode <> '528'" _
& "and TargetInstance.EventCode <> '552'" _
& "and TargetInstance.EventCode <> '2'" _
& "and TargetInstance.EventCode <> '7035'")
Do
Set objLatestEvent = colMonitoredEvents.NextEvent
Set objEmail = CreateObject("CDO.Message")
objEmail.From = ""
objEmail.To = ""
objEmail.Subject = ""
objEmail.Textbody = objLatestEvent.TargetInstance.Message & " (" & objLatestEvent.TargetInstance.TimeWritten & ", " & objLatestEvent.TargetInstance.User & ", " & objLatestEvent.TargetInstance.EventCode & ")"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ""
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = ""
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = ""
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
Loop
There are a few things that you need to configure here:
1) The From Email Address
2) The To Email Address
3) The Subject Of The Email
3) Your SMTP server - The script is setup to send email via an smtp server. Authentication is also setup to use a username/password. You can change authentication by changing the value for smtpauthenticate (eg 0 - Anon, 1 - basic, 2 - NTML)
Finally if you would like to exclude events from being emailed to you, you can do so by including an
A VBS script can be called by using the CSCRIPT.exe application and then specifying the path to the VBS file.



