Check NTBackup Log


This vbscript is really useful if you want to verify your NTBackup Log contents and send an e-mail to you with the result.
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("c:\Documents and Settings\" _
"Administrator\Impostazioni locali\Dati applicazioni" _
"Microsoft\Windows NT\NTBackup\data"
)
att_value = ""
For Each file In f.Files
if DateDiff("d",file.DateLastModified,now) = 0
and ucase(right(file.name, 3)) = "LOG" then
att_value = file.path
end if
Next

if att_value = "" then
mex = "FAILED"
result_value = "NTBackup Log Not Found"
else
Dim filesys, filetxt
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.OpenTextFile(att_value, ForReading,
, True)
strText = fileTxt.ReadAll
filetxt.close
if instr(ucase(strText), "ERROR") <> 0
or instr(ucase(strText), "UNABLE") <> 0 then
mex = "FAILED"
result_value = "Errors found"
else
mex = "SUCCESFULLY"
result_value = "Everything seems OK"

end if
End if

Dim iMsg, Flds, iConf, CorpoMessaggio
Const cdoSendUsingMethod = _
"http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort = 2
Const cdoSMTPServer = _
"http://schemas.microsoft.com/cdo/configuration/smtpserver"
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
Flds(cdoSendUsingMethod) = cdoSendUsingPort
Flds(cdoSMTPServer) = "My_SMTP_Server"
'Flds(cdoSMTPServerPort) = 25
'Flds(cdoSMTPAuthenticate) = cdoAnonymous ' 0
Flds.Update

With iMsg
Set .Configuration = iConf
.To = "receiver1@domain.com"
.Cc = "receiver2@domain.com"
.From = "Admin ServerName"
.Sender = "sender@domain.com"
.Subject = "Backup Check ServerName: " & Mex
.TextBody = result_value
if att_value <> "" then
.AddAttachment att_value
end if
.Send
End With
Share on Google Plus

About Vittorio Pavesi

    Blogger Comment
    Facebook Comment

1 commenti:

Anonymous said...

Cool Script. Works great.

I changed the line
From = "Admin ServerName"
to
From = "name@domain.com"
because of problems sending mails.