localtime = 9 ' UTF+$localtime Set objSession = CreateObject("Microsoft.Update.Session") Set objSearcher = objSession.CreateUpdateSearcher intCount = objSearcher.GetTotalHistoryCount Set colHistory = objSearcher.QueryHistory(0, intCount) wustatus = 0 additionalmsg = "" lastwudate = date() ' localtime If intCount > 0 then lastwudate = DateAdd("h",localtime,colHistory(0).Date) If DateDiff("d",lastwudate,date()) > 30 then wustatus = 1 additionalmsg = "[Warning: this system has not been updated for more than 30 days.]" End If End If For Each objHistory In colHistory wudate = DateAdd("h",9,objHistory.Date) If DateDiff("d",wudate,lastwudate) =< 7 then If objHistory.HResult = 0 then WScript.Echo wudate & ", " & objHistory.Title & ", Success" ElseIf Hex(objHistory.HResult) = 80242014 then WScript.Echo wudate & ", " & objHistory.Title & ", Success (pending reboot)" additionalmsg = "[Warning: this system is pending reboot.]" Else WScript.Echo wudate & ", " & objHistory.Title & ", Failed (error:" & Hex(objHistory.HResult) & ")" wustatus = 1 End If End If Next WScript.Echo vbNewLine & additionalmsg Wscript.Quit(wustatus)