View previous topic :: View next topic |
Author |
Message |
sysadmber
Joined: 08 Dec 2015 Posts: 50
|
Posted: Thu Jun 22, 2017 5:33 am Post subject: Registry Date parsing |
|
|
Hello,
i hope you can help me with a registry test. I want to check whether the last Windows Update is not longer than 60 days.
The Registry Key (on Servers) is
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Install\LastSuccessTime
Sample Result is: "2017-06-17 17:55:15"
In the doku i didn't find a variable for seconds so i'm unsure iof the string can currently parsed successful. I used the following Expression in the field "Alert when Value"
is > than
%yyyy-mm-dd %hh%:%nn%[-60d]%
What am i doing wrong?
Regards |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12807 Location: USA
|
Posted: Thu Jun 22, 2017 9:41 am Post subject: |
|
|
Quote: | "Alert when Value" is > than %yyyy-mm-dd %hh%:%nn%[-60d]%
What am i doing wrong? |
Everything
Should be "Alert when Value is < than %yyyy-mm-dd[-60d]%
Note: system "short date" format should be yyyy-mm-dd
Regards
Alex |
|
Back to top |
|
|
sysadmber
Joined: 08 Dec 2015 Posts: 50
|
Posted: Thu Jun 22, 2017 10:10 am Post subject: |
|
|
Thanks.
The Reply fields shows always the value read from the registry. How can i show the result of the computation?
It should show "5 Days". |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12807 Location: USA
|
Posted: Thu Jun 22, 2017 12:36 pm Post subject: |
|
|
I don't think this is possible unless you create your own shell script to check registry and return # of days to HostMonitor
e.g. Code: |
'Checks date of last installed Windows update
'====================================================================
'Start cmd: cmd /c cscript /B /E:VBScript %Script% %Params%
'Script requires 1 parameter - number of days threshold.
'====================================================================
'www.ks-soft.net
Option Explicit
const statusOk = "scriptRes:Ok:"
const statusBad = "scriptRes:Bad:"
const statusUnknown = "scriptRes:Unknown:"
Dim oWU, iTHCount, colUpdate, oUpdate, Cnt, k, Dat, objArgs, MDays
Dat = Date
Cnt = 9999999
k = 0
Set objArgs = WScript.Arguments
if objArgs.Count <> 1 then
WScript.StdOut.Write statusUnknown & "Parameter is required: <Max Days Count>"
WScript.Quit
End If
MDays = int(objArgs(0))
On Error Resume Next
Set oWU = CreateObject("Microsoft.Update.Searcher")
If Err.Number <> 0 Then
WScript.StdOut.Write statusUnknown & "WU5 programming interface does not exist.", vbInformation + vbSystemModal, "Update history"
WScript.Quit
End If
On Error Goto 0
iTHCount = oWU.GetTotalHistoryCount
If iTHCount > 0 Then
Set colUpdate = oWU.QueryHistory(0, iTHCount)
For Each oUpdate In colUpdate
if oUpdate.ResultCode = 2 then
k = DateDiff("d",oUpdate.Date,DateValue(Now))
if k<Cnt then
Cnt = k
Dat = oUpdate.Date
End If
End If
Next
if Cnt = 9999999 then
WScript.StdOut.Write statusUnknown & "Windows Updates not found"
else
If Cnt>MDays then
WScript.StdOut.Write statusBad & " Days:" & Cnt & " Last update:" & DateValue(Dat)
else
WScript.StdOut.Write statusOk & " Days:" & Cnt & " Last update:" & DateValue(Dat)
End If
End if
End If
|
Regards
Alex |
|
Back to top |
|
|
sysadmber
Joined: 08 Dec 2015 Posts: 50
|
Posted: Fri Jun 23, 2017 5:31 am Post subject: |
|
|
Thank you very much.
This did the trick. |
|
Back to top |
|
|
Kris
Joined: 12 May 2010 Posts: 375
|
Posted: Mon Jul 03, 2017 1:25 am Post subject: |
|
|
Hi Guys,
I am trying to accomplish the same.
The only difference is that the machines are on several different domains, so I need an option to send credentials along with the test.
Any ideas?
Thanks! |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12807 Location: USA
|
|
Back to top |
|
|
|