Test Windows Updates
Test Windows Updates
Hi,
We use Host Monitor 8.82.
Is there the possibility of a test to check the Windows Updates?
The test will show the number of critical Updates from the Microsoft site, have not yet been installed.
Thank you for your help
We use Host Monitor 8.82.
Is there the possibility of a test to check the Windows Updates?
The test will show the number of critical Updates from the Microsoft site, have not yet been installed.
Thank you for your help
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
Test Windows Updates
You may use Shell Script test method and custom made script.
E.g. script may look like the following:
'============================================================================
Option Explicit
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
dim objInstallationBehavior
dim i, cnt
Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateupdateSearcher()
Set searchResult = _
updateSearcher.Search("IsInstalled=0 and Type='Software'")
cnt = 0
FOR i = 0 to searchResult.Updates.Count-1
Set objInstallationBehavior = searchResult.Updates.Item(i).InstallationBehavior
IF objInstallationBehavior.Impact=2 then
cnt = cnt+1 'high impact updates
ELSE
'WScript.StdOut.WriteLine searchResult.Updates.Item(i).Title & ", Impact: " & objInstallationBehavior.Impact
END IF
NEXT
if cnt>0 then
WScript.StdOut.Write statusBad & searchResult.Updates.Count & " critical updates found!"
else
WScript.StdOut.Write statusOk 'No new critical updates found
End If
'============================================================================
'Start cmd: cmd /c cscript /B /E:VBScript %Script% %Params%
'============================================================================
Please note: Script execution may take much time. You should set higher Timeout for script execution.
E.g. script may look like the following:
'============================================================================
Option Explicit
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
dim objInstallationBehavior
dim i, cnt
Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateupdateSearcher()
Set searchResult = _
updateSearcher.Search("IsInstalled=0 and Type='Software'")
cnt = 0
FOR i = 0 to searchResult.Updates.Count-1
Set objInstallationBehavior = searchResult.Updates.Item(i).InstallationBehavior
IF objInstallationBehavior.Impact=2 then
cnt = cnt+1 'high impact updates
ELSE
'WScript.StdOut.WriteLine searchResult.Updates.Item(i).Title & ", Impact: " & objInstallationBehavior.Impact
END IF
NEXT
if cnt>0 then
WScript.StdOut.Write statusBad & searchResult.Updates.Count & " critical updates found!"
else
WScript.StdOut.Write statusOk 'No new critical updates found
End If
'============================================================================
'Start cmd: cmd /c cscript /B /E:VBScript %Script% %Params%
'============================================================================
Please note: Script execution may take much time. You should set higher Timeout for script execution.
Hi, many thanks for the quick response.
how do I now install the script exactly?
the script must be stored on the server, I would like to monitor?
Or copy to my host monitor server?
Do I need a new test script?
there must be the only path to the specified script file, or more parameters so that the test works
Thank you for your help
how do I now install the script exactly?
the script must be stored on the server, I would like to monitor?
Or copy to my host monitor server?
Do I need a new test script?
there must be the only path to the specified script file, or more parameters so that the test works
Thank you for your help
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
Test Windows Updates
how do I now install the script exactly?
the script must be stored on the server, I would like to monitor?
Or copy to my host monitor server?
This script is designed for ShellScript test method :http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell
You should create new ShellScript test (menu Test->New->Shell Script Test -> Script Manager)
Script Manager is used to store and test scripts.
Please check the manual or visit our web site for more information:
http://www.ks-soft.net/hostmon.eng/mfra ... m#shellmng
Sure, see above.Do I need a new test script?
This script does not require any parameters.here must be the only path to the specified script file, or more parameters so that the test works
You should use Start cmd in Script Manager like: cmd /c cscript /B /E:VBScript %Script% %Params%
Hi,
The test wokrs now fine.
One more question for this test:
How can I make the following query?
0 updates => display "No important windows updates"
1 update => display "one important windowns Update
more then one => display "xx important windows updates available "
Because in the German language, there are several variations of the word important
1 = wichtiges
more then one = wichtige
Thank you for your help
The test wokrs now fine.
One more question for this test:
How can I make the following query?
0 updates => display "No important windows updates"
1 update => display "one important windowns Update
more then one => display "xx important windows updates available "
Because in the German language, there are several variations of the word important
1 = wichtiges
more then one = wichtige
Thank you for your help
You may change script in any way you wantHow can I make the following query?
0 updates => display "No important windows updates"
1 update => display "one important windowns Update
more then one => display "xx important windows updates available "
E.g.
Code: Select all
if cnt>1 then
WScript.StdOut.Write statusBad & searchResult.Updates.Count & "text1"
elseif cnt=1 then
WScript.StdOut.Write statusBad & searchResult.Updates.Count & "text2"
else
WScript.StdOut.Write statusOk "text3"
End If
Alex
hi,
many thanks for the helpful response.
I knew the parameters elseif not.
At the momment I have the problem when ther is a server with no critical updates I always get the message:
error: script returns no results
But I can not find the error.
Any idea where I assumed something wrong?
My script now looks like this.
-------------------------------------------------------------------------------------
Option Explicit
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
dim objInstallationBehavior
dim i, cnt
Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateupdateSearcher()
Set searchResult = _
updateSearcher.Search("IsInstalled=0 and Type='Software'")
cnt = 0
FOR i = 0 to searchResult.Updates.Count-1
Set objInstallationBehavior = searchResult.Updates.Item(i).InstallationBehavior
IF objInstallationBehavior.Impact=2 then
cnt = cnt+1 'high impact updates
ELSE
'WScript.StdOut.WriteLine searchResult.Updates.Item(i).Title & ", Impact: " & objInstallationBehavior.Impact
END IF
NEXT
cnt>1 then
WScript.StdOut.Write statusOk & searchResult.Updates.Count & " wichtiges Windows-Updates steht zur Installation bereit"
elseif cnt=1 then
WScript.StdOut.Write statusOk & searchResult.Updates.Count & " wichtige Windows-Update stehen zur Installation bereit"
else
WScript.StdOut.Write statusbad & " Keine wichtigen Windows-Updates stehen zur Instalaltion bereit "
End If
-------------------------------------------------------------------------------------
Thank you for your help
many thanks for the helpful response.
I knew the parameters elseif not.
At the momment I have the problem when ther is a server with no critical updates I always get the message:
error: script returns no results
But I can not find the error.
Any idea where I assumed something wrong?
My script now looks like this.
-------------------------------------------------------------------------------------
Option Explicit
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
dim objInstallationBehavior
dim i, cnt
Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateupdateSearcher()
Set searchResult = _
updateSearcher.Search("IsInstalled=0 and Type='Software'")
cnt = 0
FOR i = 0 to searchResult.Updates.Count-1
Set objInstallationBehavior = searchResult.Updates.Item(i).InstallationBehavior
IF objInstallationBehavior.Impact=2 then
cnt = cnt+1 'high impact updates
ELSE
'WScript.StdOut.WriteLine searchResult.Updates.Item(i).Title & ", Impact: " & objInstallationBehavior.Impact
END IF
NEXT
cnt>1 then
WScript.StdOut.Write statusOk & searchResult.Updates.Count & " wichtiges Windows-Updates steht zur Installation bereit"
elseif cnt=1 then
WScript.StdOut.Write statusOk & searchResult.Updates.Count & " wichtige Windows-Update stehen zur Installation bereit"
else
WScript.StdOut.Write statusbad & " Keine wichtigen Windows-Updates stehen zur Instalaltion bereit "
End If
-------------------------------------------------------------------------------------
Thank you for your help
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
ShellScript returns "error: script returns no results" error when there is an error in script.
I think you missed If statement here:
If cnt>1 then
WScript.StdOut.Write statusOk & searchResult.Updates.Count & " wichtiges Windows-Updates steht zur Installation bereit"
elseif cnt=1 then
WScript.StdOut.Write statusOk & searchResult.Updates.Count & " wichtige Windows-Update stehen zur Installation bereit"
else
WScript.StdOut.Write statusbad & " Keine wichtigen Windows-Updates stehen zur Instalaltion bereit "
End If
I think you missed If statement here:
If cnt>1 then
WScript.StdOut.Write statusOk & searchResult.Updates.Count & " wichtiges Windows-Updates steht zur Installation bereit"
elseif cnt=1 then
WScript.StdOut.Write statusOk & searchResult.Updates.Count & " wichtige Windows-Update stehen zur Installation bereit"
else
WScript.StdOut.Write statusbad & " Keine wichtigen Windows-Updates stehen zur Instalaltion bereit "
End If
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
I have modified script. Now it should retrieve updates count from another system.
Script can accept one parameter - name (or IP) of remote machine.
Please note: user account, under wich script is started, should have administrator privileges on remote machine.
Script can accept one parameter - name (or IP) of remote machine.
Code: Select all
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
dim objInstallationBehavior
dim i, cnt
Set objArgs = WScript.Arguments
if objArgs.count = 0 then
Set updateSession = CreateObject("Microsoft.Update.Session")
else
Set updateSession = CreateObject("Microsoft.Update.Session",objArgs(0))
end if
if Err.Number <> 0 then
WScript.StdOut.Write statusUnknown & Err.Description
WScript.Quit
end if
Set updateSearcher = updateSession.CreateupdateSearcher()
Set searchResult = _
updateSearcher.Search("IsInstalled=0 and Type='Software'")
cnt = 0
FOR i = 0 to searchResult.Updates.Count-1
Set objInstallationBehavior = searchResult.Updates.Item(i).InstallationBehavior
IF objInstallationBehavior.Impact=2 then
cnt = cnt+1 'high impact updates
ELSE
'WScript.StdOut.WriteLine searchResult.Updates.Item(i).Title & ", Impact: " & objInstallationBehavior.Impact
END IF
NEXT
If cnt>1 then
WScript.StdOut.Write statusOk & searchResult.Updates.Count & " wichtiges Windows-Updates steht zur Installation bereit"
elseif cnt=1 then
WScript.StdOut.Write statusOk & searchResult.Updates.Count & " wichtige Windows-Update stehen zur Installation bereit"
else
WScript.StdOut.Write statusbad & " Keine wichtigen Windows-Updates stehen zur Instalaltion bereit "
End If
Hi,
this is my first test in hostmoni with shell script.
I have Hostmoni Version 8.68.
In the Script Manager i create a new script an copied the Script.
Now what do i have to enter under Hint and Prams?
On start cmd i enter cmd /c cscript /B /C:windowsupdate.vbs %Script% %Params%
When ein Test the Script Hostmoni says Error: unable to start script.
Can you help me?
this is my first test in hostmoni with shell script.
I have Hostmoni Version 8.68.
In the Script Manager i create a new script an copied the Script.
Now what do i have to enter under Hint and Prams?
On start cmd i enter cmd /c cscript /B /C:windowsupdate.vbs %Script% %Params%
When ein Test the Script Hostmoni says Error: unable to start script.
Can you help me?
This does not look correctly.cmd /c cscript /B /C:windowsupdate.vbs %Script% %Params%
1) I think cscript utility does not support such /C parameter
2) If you stored script in external file (windowsupdate.vbs) then you don't need to use %Script% variable. If you stored script using Script Manager then you need to use %Script% variable but then windowsupdate.vbs has no sense.
As you may see VB script example uses the following command
cmd /c cscript /B /E:VBScript %Script% %Params%
Why don't you use the same command?
Quote fro the manualNow what do i have to enter under Hint and Prams?
=================
Hint
List of script parameters (if any). This parameter is optional however we recommend to use it. It will be displayed in the Test Properties dialog as a reminder - which parameters should be specified for the script. E.g. "Process: %CPU usage (average)" script has 2 parameters: <process_name> and <maximum threshold (%)>
=================
So you may use this field for any information useful for you.
Parameter?
As Tom said script can accept one parameter - name (or IP) of remote machine.
Regards
Alex
I am having a tough time with a modification. On windows 2003 the script provided here in this forum will check for "High Priority" and "Software, Optional" updates. I would like it to check only for "High Priority".
I found the following script on the internet that checks "High Priority" updates only but I am having difficulty merging the two scripts together to make it work.
I believe I am close to getting this to work but I am stuck so far woth this.
[/quote]
I found the following script on the internet that checks "High Priority" updates only but I am having difficulty merging the two scripts together to make it work.
Code: Select all
' check this category for 'High Priority' updates
category = "UpdateClassification"
highpriority = ",Security Updates,Update Rollups,Critical Updates,"
' create instance of update.searcher (offline)
Set objSearcher = CreateObject("Microsoft.Update.Searcher")
objSearcher.Online = 1
' find and fetch collection of updates
Set objResults = objSearcher.Search("Type='Software' and IsInstalled=0")
Set colUpdates = objResults.Updates
count = 0
titles = ""
For i = 0 to colUpdates.Count - 1
' check categories
Set colCategories = colUpdates.Item(i).Categories
For c = 0 to colCategories.Count - 1
If colCategories.item(c).Type = category _
And InStr(highPriority, "," & colCategories.item(c).Name & ",") > 0 Then
count = count + 1
titles = titles & vbCRLF & colUpdates.Item(i).Title
End If
Next
Next
If count > 0 Then
Wscript.Echo count & " pending updates:" & titles
Wscript.Quit 2
Else
Wscript.Echo "No pending updates"
Wscript.Quit 0
End If
Code: Select all
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:"
' check this category for 'High Priority' updates
category = "UpdateClassification"
highpriority = ",Security Updates,Update Rollups,Critical Updates,"
' create instance of update.searcher (offline)
Set objSearcher = CreateObject("Microsoft.Update.Searcher")
objSearcher.Online = 1
' find and fetch collection of updates
Set objResults = objSearcher.Search("Type='Software' and IsInstalled=0")
Set colUpdates = objResults.Updates
count = 0
titles = ""
For i = 0 to colUpdates.Count - 1
' check categories
Set colCategories = colUpdates.Item(i).Categories
For c = 0 to colCategories.Count - 1
If colCategories.item(c).Type = category _
And InStr(highPriority, "," & colCategories.item(c).Name & ",") > 0 Then
count = count + 1
titles = titles & vbCRLF & colUpdates.Item(i).Title
End If
Next
Next
if count > 0 then
WScript.StdOut.Write statusBad & colupdates.Updates.Count & " critical updates found!"
else
WScript.StdOut.Write statusOk 'No new critical updates found
End If
'If count > 0 Then
'Wscript.Echo count & " pending updates:" & titles
'Wscript.Quit 2
'Else
'Wscript.Echo "No pending updates"
'Wscript.Quit 0
'End If