Step1- Create batch file and save Time-Event.bat

@echo off
del C:\IT-Scripts\Time-Event\Time-Event.txt
wevtutil qe security /rd:true /f:text /c:1 /q:"*[System/EventID=4616]" > file.txt >>C:\IT-Scripts\Time-Event\Time-Event.txt
wscript "C:\IT-Scripts\Time-Event\Time-Event-Notification.vbs"

Step2 -Creat VB Script and save Time-Event-Notification.vbs

Dim objEmail
Set objEmail = CreateObject("CDO.Message")

'************************************
'** Seting basic email information **
'************************************
Const EmailFrom = "[email protected]"
Const EmailTo = "[email protected]"
Const EmailSubject = "WEB Time Changed"

'***************************************
'** Setting Mail Server Configuration **
'***************************************
Const MailSendUsing = "2"
Const MailSendServer = "your_smtp_server"
Const MailSendPort = "25"
'Const MailSendUsername = "[email protected]"
'Const MailSendPassword = "mypassword"
'Const MailSendAuthenticationType = "1"

'**************************************
'** Email Parameters (DO NOT CHANGE) **
'**************************************
objEmail.From = EmailFrom
objEmail.To = EmailTo
objEmail.Subject = EmailSubject
objEmail.Textbody = EmailBody
objEmail.AddAttachment EmailAttachments
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = MailSendUsing
ObjEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = MailSendServer
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = MailSendPort
'objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = MailSendAuthenticationType
'objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = MailSendUsername
'objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = MailSendPassword

'*******************************************************
'** Setting a text file to be shown in the email Body **
'*******************************************************
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
'** File to be inserted in Body
Const FileToBeUsed = "C:\IT-Scripts\Time-Event\Time-Event.txt"
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
'** Open the file for reading
Set f = fso.OpenTextFile(FileToBeUsed, ForReading)
'** The ReadAll method reads the entire file into the variable BodyText
objEmail.Textbody = f.ReadAll
'** Close the file
f.Close
'** Clear variables
Set f = Nothing
Set fso = Nothing

'* cdoSendUsingPickup (1)
'* cdoSendUsingPort (2)
'* cdoSendUsingExchange (3)

'********************************
'** Parameters (DO NOT CHANGE) **
'********************************
ObjEmail.Configuration.Fields.Update
objEmail.Send

Step3- Open event viewer go to security change server time and find event id 4616 from filter

Step4- Right click on event id :

Step5- On the task in action add your batch file

Step6- Open your Task Schedualer find alert and check Run with highest  privileges

 

Now Enjoy your alert bu email đŸ™‚

 

Leave a comment

Your email address will not be published. Required fields are marked *