View previous topic :: View next topic |
Author |
Message |
vindicta
Joined: 02 Jan 2014 Posts: 11
|
Posted: Thu Jan 02, 2014 4:48 am Post subject: Check how many windows update are available for servers |
|
|
Hello,
I know there was a topic before to check for windows updates, but the active script in there was not working.
So that is why I try it again?
Does anyone has an script to check how many windows updates are available on al lot of windows 2008 - windows 2012 servers? I need to check these servers (all remote) and want a number in return.
I hope someone can help me with that. |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Thu Jan 02, 2014 10:57 am Post subject: |
|
|
Quote: | I know there was a topic before to check for windows updates, but the active script in there was not working. |
What exactly script you are using?
What exactly means "not working"? What error do you see?
Quote: | Does anyone has an script to check how many windows updates are available on al lot of windows 2008 - windows 2012 servers? I need to check these servers (all remote) and want a number in return. |
If you can use single admin account for all remote systems, try this script
(Shell Script test method, 1 parameter - target hostname)
Code: | 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
if objArgs.Count>1 then
strComputer = objArgs(0)
Set updateSession = CreateObject
("Microsoft.Update.Session",strComputer)
Set updateSearcher = updateSession.CreateupdateSearcher()
Set searchResult = updateSearcher.Search("IsInstalled=0 and Type='Software'")
if searchResult.Updates.Count>0 then
WScript.StdOut.Write statusBad & searchResult.Updates.Count & " updates found!"
else
WScript.StdOut.Write statusOk & "No new updates found."
End If
else
WScript.StdOut.WriteLine statusUnknown & "Not enough parameters specified"
end if |
Regards
Alex |
|
Back to top |
|
|
vindicta
Joined: 02 Jan 2014 Posts: 11
|
Posted: Thu Jan 02, 2014 1:45 pm Post subject: |
|
|
Hi Alex,
Thank you for your fast respons.
I tried all the sripts in this thread:
http://www.ks-soft.net/cgi-bin/phpBB/viewtopic.php?t=6332&highlight=windows+update
I have many servers in different vlan's with different admin accounts, but in every vlan is a domain controller upon which I have installed an r.m.a. agent.
So basically i can use the scipt you provided in this thread, because I can use
the r.m.a. agent needed for the specific server.
When I use your script, I get an unknown error.
This is my 'start cmd' cmd /c cscript /B /E:VBScript %Script% %Params%
then your script and in the field 'Params' I type in the name of the server. Even localhost or the IP-address gives me the unknown error.
Maybe I overlooked something? |
|
Back to top |
|
|
vindicta
Joined: 02 Jan 2014 Posts: 11
|
Posted: Thu Jan 02, 2014 2:22 pm Post subject: |
|
|
Hi Alex,
This script seems to work:
Code: | 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,Service Packs"
' 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 |
But then again, i cannot give in a servername.
And I see now that it gives me the 'OK' status..but i have Windows 2008 Service Pack 2 as important update not yet installed. And I see this in my Windows Update screen. |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Thu Jan 02, 2014 2:35 pm Post subject: |
|
|
Added some error checking.
No parameters should be specified for local system.
Or one parameter - host name/IP of target system
Code: | 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.Search("IsInstalled=0 and Type='Software'")
checkForError(4)
if searchResult.Updates.Count>0 then
WScript.StdOut.Write statusBad & searchResult.Updates.Count & " updates found!"
else
WScript.StdOut.Write statusOk & "No new updates found."
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 |
|
|
vindicta
Joined: 02 Jan 2014 Posts: 11
|
Posted: Thu Jan 02, 2014 2:40 pm Post subject: |
|
|
Strange issue is happening:
When i use the scipt you just posted and test it like a normal test. I gives me the 'Bad' status reply.
When i test in the Shell Script screen i get this result:
[9:38:18 PM] HostMonitor is going to execute "WindowsUpdate -alex van forum" script ...
[9:38:26 PM] Script executed, correct result received:
----------
- Status: Bad
- Reply: 2 updates found!
----------
Also a kind of strange, because i see only 1 update ready in the windows update screen. |
|
Back to top |
|
|
vindicta
Joined: 02 Jan 2014 Posts: 11
|
Posted: Thu Jan 02, 2014 2:55 pm Post subject: |
|
|
And when i use the Shell Script screen and test with an R.M.A agent and a parameter (the server name). I get this:
[9:53:25 PM] Agent: active-ade-amf-sbs001.-----.local is going to execute "WindowsUpdate -alex van forum" script ...
[9:53:35 PM] Agent error: no responce from agent within specified timeout
Even with a timeout of 600 sec. |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Thu Jan 02, 2014 2:58 pm Post subject: |
|
|
Quote: | trange issue is happening:
When i use the scipt you just posted and test it like a normal test. I gives me the 'Bad' status reply.
When i test in the Shell Script screen i get this result: |
"Shell Script screen" also returns Bad status (more than 0 updates found.)
You may show update name using searchResult.Updates.Item(0)
Script that shows last available Update may look like the following:
Quote: | 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.Search("IsInstalled=0 and Type='Software'")
checkForError(4)
if searchResult.Updates.Count>0 then
WScript.StdOut.Write statusBad & searchResult.Updates.Count & " updates found. (last: " & searchResult.Updates.Item(searchResult.Updates.Count-1) & ")"
else
WScript.StdOut.Write statusOk & "No new updates found."
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 |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Thu Jan 02, 2014 3:39 pm Post subject: |
|
|
Quote: | [9:53:25 PM] Agent: active-ade-amf-sbs001.-----.local is going to execute "WindowsUpdate -alex van forum" script ...
[9:53:35 PM] Agent error: no responce from agent within specified timeout Even with a timeout of 600 sec. |
Try to start script manually on RMA system without "/B" command line switch
RMA started as service?
what account do you use to run agent?
UAC enabled?
Regards
Alex |
|
Back to top |
|
|
vindicta
Joined: 02 Jan 2014 Posts: 11
|
Posted: Thu Jan 02, 2014 3:41 pm Post subject: |
|
|
That, gives me this answer:
[10:39:11 PM] Script executed, correct result received:
----------
- Status: Bad
- Reply: 2 updates found. (last: Microsoft .NET Framework 4 for Windows Server 2008 x64-based Systems (KB982671))
----------
But still in hostmonitor itself it only says: Bad. (not why, or how many).
And remote isn't working as I described.
Sorry to bother you with this.. |
|
Back to top |
|
|
vindicta
Joined: 02 Jan 2014 Posts: 11
|
Posted: Thu Jan 02, 2014 3:46 pm Post subject: |
|
|
KS-Soft wrote: | Quote: | [9:53:25 PM] Agent: active-ade-amf-sbs001.-----.local is going to execute "WindowsUpdate -alex van forum" script ...
[9:53:35 PM] Agent error: no responce from agent within specified timeout Even with a timeout of 600 sec. |
Try to start script manually on RMA system without "/B" command line switch
Doesn't work.
RMA started as service?
Yes
what account do you use to run agent?
New created domain-admin account.
UAC enabled?
User Access Control is disabled.
Regards
Alex |
|
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Thu Jan 02, 2014 5:22 pm Post subject: |
|
|
Quote: | Try to start script manually on RMA system without "/B" command line switch
Doesn't work. |
What exactly means does not work? What exactly error message do you see?
Regards
Alex |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Thu Jan 02, 2014 5:27 pm Post subject: |
|
|
Quote: | - Status: Bad
- Reply: 2 updates found. (last: Microsoft .NET Framework 4 for Windows Server 2008 x64-based Systems (KB982671))
----------
But still in hostmonitor itself it only says: Bad. (not why, or how many).
----------
if searchResult.Updates.Count>0 then
WScript.StdOut.Write statusBad & searchResult.Updates.Count & " updates found. (last: " & searchResult.Updates.Item(searchResult.Updates.Count-1) & ")" |
Don't see how this may happen only one command in script may return Bad status and this command returns searchResult.Updates.Count as well
Could you please send screen shots to support@ks-soft.net?
Regards
Alex |
|
Back to top |
|
|
vindicta
Joined: 02 Jan 2014 Posts: 11
|
Posted: Fri Jan 03, 2014 4:05 am Post subject: |
|
|
See your mail. The local-server is solved. I see now that there are 2 updates pending. And the name of the last.
But my remote servers still gives me a time-out when I try it via 'Lets Try' screen. |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Mon Jan 06, 2014 8:33 am Post subject: |
|
|
resume: script works, timeout was too short
Regards
Alex |
|
Back to top |
|
|
|