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

Test Windows Updates
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting
View previous topic :: View next topic  
Author Message
chri



Joined: 09 Mar 2009
Posts: 19

PostPosted: Wed Jun 25, 2014 12:26 am    Post subject: Reply with quote

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



Joined: 16 May 2006
Posts: 2832

PostPosted: Wed Jun 25, 2014 1:22 am    Post subject: Reply with quote

Thank you for sharing.
Back to top
View user's profile Send private message Send e-mail 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
Goto page Previous  1, 2, 3
Page 3 of 3

 
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