KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Registry Date parsing

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting
View previous topic :: View next topic  
Author Message
sysadmber



Joined: 08 Dec 2015
Posts: 50

PostPosted: Thu Jun 22, 2017 5:33 am    Post subject: Registry Date parsing Reply with quote

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
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12792
Location: USA

PostPosted: Thu Jun 22, 2017 9:41 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
sysadmber



Joined: 08 Dec 2015
Posts: 50

PostPosted: Thu Jun 22, 2017 10:10 am    Post subject: Reply with quote

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
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12792
Location: USA

PostPosted: Thu Jun 22, 2017 12:36 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
sysadmber



Joined: 08 Dec 2015
Posts: 50

PostPosted: Fri Jun 23, 2017 5:31 am    Post subject: Reply with quote

Thank you very much.

This did the trick.
Back to top
View user's profile Send private message
Kris



Joined: 12 May 2010
Posts: 375

PostPosted: Mon Jul 03, 2017 1:25 am    Post subject: Reply with quote

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
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12792
Location: USA

PostPosted: Mon Jul 03, 2017 4:46 am    Post subject: Reply with quote

For security and reliability we always recommend to install RMA agent when you need to check several LANs/domains
http://www.ks-soft.net/hostmon.eng/rma-win/index.htm

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index