we made a Little modification and we now get "how many days are gone since the Server has installed the last updates"
start cmd: cmd /c cscript /B /E:VBScript %Script% %Params%
Parameter: "ServerName" xx (in days before alert)
script:
Option Explicit
On Error Resume Next
const statusAlive = "scriptRes:Host is alive:"
const statusDead = "scriptRes:No answer:"
const statusUnknown = "scriptRes:Unknown:"
const statusNotResolved = "scriptRes:Unknown host:"
const statusOk = "scriptRes:Ok:"
const statusBad = "scriptRes:Bad:"
const statusBadContents = "scriptRes:Bad contents:"
dim updateSession, updateSearcher, searchResult, objArgs
Set objArgs = WScript.Arguments
checkForError(1)
if objArgs.Count=0 Then
Set updateSession = CreateObject("Microsoft.Update.Session")
else
Set updateSession = CreateObject("Microsoft.Update.Session",objArgs(0))
end if
checkForError(2)
Set updateSearcher = updateSession.CreateupdateSearcher()
checkForError(3)
Set searchResult = updateSearcher.QueryHistory(1,1)
checkForError(4)
if searchResult.Count>0 then
' wscript.echo int(datediff("d", searchresult.item(0).date,now))
if int(datediff("d", searchresult.item(0).date,now)) > int(objArgs(1)) then
wscript.stdout.write statusBad & datediff("d", searchresult.item(0).date,now)
else
wscript.stdout.write statusOk & datediff("d", searchresult.item(0).date,now)
end if
else
WScript.StdOut.Write statusBad & "No updates installed."
End If
Sub checkForError(txt)
If Err.Number <> 0 Then
WScript.StdOut.Write statusUnknown & "(" & txt & ") " &Err.Description
WScript.Quit
End If
End Sub
Test Windows Updates
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact: