strEmailTo="[email protected]"
strEmailFrom="DNS monitor"
strDomain="yourdomain.com"
strDNSServer="4.2.2.2"
strSMTPServer="yoursmtpserver"
iSMTPPort=25
Do
Set objShell = CreateObject("WScript.Shell")
Set objNSLookup = objShell.Exec("nslookup -q=MX "&strDomain&" "&strDNSServer)
Set objStdOut = objNSLookup.StdOut
strOutput = objStdOut.ReadAll
bChanged=False
If Instr(strOutput,strDomain&vbTab&"MX preference = 8, mail exchanger = "&strDomain&".s5b2.pts.com")=0 then bChanged=True
If Instr(strOutput,strDomain&vbTab&"MX preference = 2, mail exchanger = "&strDomain&".s5a1.pts.com")=0 then bChanged=True
If Instr(strOutput,strDomain&vbTab&"MX preference = 4, mail exchanger = "&strDomain&".s5a2.pts.com")=0 then bChanged=True
If Instr(strOutput,strDomain&vbTab&"MX preference = 6, mail exchanger = "&strDomain&".s5b1.pts.com")=0 then bChanged=True
If bChanged=True then
Set objEmail = CreateObject("CDO.Message")
objEmail.From = strEmailFrom
objEmail.To = strEmailTo
objEmail.Subject = "DNS changed"
objEmail.Textbody = strOutput
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPServer
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = iSMTPPort
objEmail.Configuration.Fields.Update
objEmail.Send
wscript.quit
End If
wscript.sleep 60000
Loop
|