Set it to run daily in Task Manager (or other scheduler of your choice), it checks your windows update situation on the server and send you a nicely formatted email to your inbox.
This script is taken from http://www.tachytelic.net/2007/08/windo ... ification/ - screenshot also provided there of the email you receive. I have adapted it for Hmailserver emailing, buy left the original emailing feature by CDO in there (REMmed).
1, Change email addresses accordingly.
2, Set preferences to your 'Alert' levels (set to 1 where required) and server connection/port details.
3, Download and extract UPDATETEMPLATE.HTM (attached as a Zip) and save in the same location as the script.
Code: Select all
' Taken from http://www.tachytelic.net/2007/08/windows-update-automatic-e-mail-notification/
'
'==========================================================================
' NAME: Windows update automatic e-mail notification
' AUTHOR: Paul Murana, Accendo Solutions
' DATE : 26/08/2007
'==========================================================================
'Change these variables to control which updates trigger an e-mail alert
'and to configure e-mail from/to addresses
AlertCritical = 1
AlertImportant = 1
AlertModerate = 1
AlertLow = 1
EmailFrom = "ServerAdmin <server@mydomain.net>"
EmailFromAdd = "server@mydomain.net"
EmailTo = "gareth@mydomain.net"
RemoteSMTPServer= ""
RemoteSMTPPort = "25"
Const HMSADMINUSER = "Administrator" ' Admin username
Const HMSADMINPWD = "secret" ' Admin password
'==========================================================================
Set fso = CreateObject("Scripting.FileSystemObject")
Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateupdateSearcher()
Set oShell = CreateObject( "WScript.Shell" )
computername = oShell.ExpandEnvironmentStrings("%ComputerName%")
DomainName = oShell.ExpandEnvironmentStrings("%userdomain%")
EMailSubject = "Windows Update Notification - " & DomainName & "\" & computername
Set oshell = Nothing
Set searchResult = updateSearcher.Search("IsInstalled=0 and Type='Software' and IsHidden=0")
If searchResult.Updates.count > 0 Then
For I = 0 To searchResult.Updates.Count-1
Set update = searchResult.Updates.Item(I)
WScript.Echo update.Title & " '"&update.MsrcSeverity&"'"
severity="'"&update.MsrcSeverity&"'"
' Select Case update.MsrcSeverity
Select Case severity
Case "'Critical'"
CriticalCount = Criticalcount+1
CriticalHTML = CriticalHTML & MakeHTMLLine(update)
Case "'Important'"
ImportantCount = Importantcount + 1
ImportantHTML = ImportantHTML & MakeHTMLLine(update)
' Next added to incorporate missing severity report (seems common) and default assume them to IMPORTANT
Case "''"
ImportantCount = Importantcount + 1
ImportantHTML = ImportantHTML & MakeHTMLLine(update)
Case "Moderate"
ModerateCount = Moderatecount + 1
ModerateHTML = ModerateHTML & MakeHTMLLine(update)
Case "Low"
Lowcount = Lowcount + 1
LowHTML = LowHTML & MakeHTMLLine(update)
end select
Next
If searchResult.Updates.Count = 0 Then
WScript.Quit
Else
WScript.Echo "A"&AlertCritical & " B"&CriticalCount & " C"&AlertImportant & " D"&ImportantCount & " E"&AlertModerate & " F"&ModerateCount & " G"&AlertLow & " H"&LowCount
If (AlertCritical=1 and CriticalCount > 0) then SendEmail=1 end if
If (AlertImportant=1 and ImportantCount > 0) then SendEmail=1 end if
If (AlertModerate=1 and ModerateCount > 0) then SendEmail=1 end if
If (AlertLow=1 and LowCount > 0) then SendEmail=1 end If
if SendEmail=1 Then
' ***********this section bespoke to match hamilserver ***************
Set oApp = CreateObject("hMailServer.Application")
Call oApp.Authenticate(HMSADMINUSER, HMSADMINPWD)
Set Message = CreateObject("hMailServer.Message")
Message.FromAddress = EmailFromAdd
Message.From = EmailFrom
Message.AddRecipient "System Administrator", EmailTo
Message.Subject = EMailSubject
Message.HTMLBody = ReplaceHTMLTemplate()
Message.Save
' ***********this section bespoke to match hamilserver ***************
' Set objMessage = CreateObject("CDO.Message")
' objMessage.Subject = EMailSubject
' objMessage.From = EmailFrom
' objMessage.To = EmailTo
' objMessage.HTMLBody = ReplaceHTMLTemplate()
' if RemoteSMTPServer <> "" then
' objMessage.Configuration.Fields.Item ("http://schemas.microsoft.net/cdo/configuration/sendusing") = 2
' objMessage.Configuration.Fields.Item ("http://schemas.microsoft.net/cdo/configuration/smtpserver") = RemoteSMTPServer
' objMessage.Configuration.Fields.Item ("http://schemas.microsoft.net/cdo/configuration/smtpserverport") = RemoteSMTPPort
' objMessage.Configuration.Fields.Update
' end if
' objMessage.Send
end if
end If
End If
Function MakeHTMLLine(update)
HTMLLine="<tr><td>" & update.Title & "</td><td>" & update.description & "</td><td>"
counter =0
For Each Article in Update.KBArticleIDs
if counter > 0 then HTMLLine=HTMLLine & "<BR>"
HTMLLine=HTMLLine & "<a href=" & chr(34) & "http://support.microsoft.net/kb/" & article & "/en-us" & chr(34) & ">KB" & article & "</a>"
counter = counter +1
Next
For Each Info in Update.moreinfourls
if counter > 0 then HTMLLine=HTMLLine & "<BR>"
HTMLLine=HTMLLine & "<a href=" & chr(34) & info & chr(34) & ">" & "More information...</a>"
counter = counter +1
Next
HTMLLine = HTMLLine & "</td></tr>"
MakeHTMLLine = HTMLLine
End function
Function ReplaceHTMLTemplate()
Set HTMLFile = fso.opentextfile((fso.GetParentFolderName(WScript.ScriptFullName) & "\updatetemplate.htm"),1,false)
MasterHTML = HTMLFile.Readall
HTMLFile.close
MasterHTML = Replace(MasterHTML, "[criticalupdatecontents]", CriticalHTML)
MasterHTML = Replace(MasterHTML, "[importantupdatecontents]", ImportantHTML)
MasterHTML = Replace(MasterHTML, "[moderateupdatecontents]", ModerateHTML)
MasterHTML = Replace(MasterHTML, "[lowupdatecontents]", LowHTML)
MasterHTML = Replace(MasterHTML, "[computername]", Computername)
MasterHTML = Replace(MasterHTML, "[domainname]", domainname)
MasterHTML = Replace(MasterHTML, "[timenow]", now())
If (CriticalCount = 0) then
MasterHTML = TrimSection(MasterHTML, "<!--CriticalStart-->", "<!--CriticalEnd-->")
end if
If (ImportantCount = 0) then
MasterHTML = TrimSection(MasterHTML, "<!--ImportantStart-->", "<!--ImportantEnd-->")
end if
If (moderateCount = 0) then
MasterHTML = TrimSection(MasterHTML, "<!--ModerateStart-->", "<!--ModerateEnd-->")
end if
If (LowCount = 0) then
MasterHTML = TrimSection(MasterHTML, "<!--LowStart-->", "<!--LowEnd-->")
end if
ReplaceHTMLTemplate = MasterHTML
End Function
Function TrimSection(CompleteString,LeftString,RightString)
LeftChunkPos=inStr(CompleteString, LeftString)
RightChunkPos=inStrRev(CompleteString, Rightstring)
LeftChunk=Left(CompleteString, LeftChunkPos-1)
RightChunk=mid(CompleteString, RightChunkPos)
TrimSection=LeftChunk & RightChunk
End Function