View Full Version : check for windows updates
colin7151
18-10-2006, 21:37
Hey guys,
Dose anyone have any ideas how I could set it up so the agent did a check to see if there were any outstanding windows updates that needed to be isntalled on the box it was installed on?
Im use to a *nix enviorment so im not sure how to do this on windows, i googled around but couldnt fine anything all that helpfull.
Perhaps wupdmgr.exe has usefull commande line switches (I have no winbox here to check) that you could parse with a short shell script (wsh, vb, ...), use in a UserParameter (or system.run) ?
colin7151
25-10-2006, 00:52
Perhaps wupdmgr.exe has usefull commande line switches (I have no winbox here to check) that you could parse with a short shell script (wsh, vb, ...), use in a UserParameter (or system.run) ?
Yeah that would be cool, however i have not been able to find a way to get anything useful out of wupdmgr.exe.
Dose anyone have experience doing such a thing, or know if its even possible?
peter_field
29-11-2006, 07:19
I would like something like this also. However, I have currently settled for this solution:
http://www.zabbix.com/forum/showpost.php?p=15341&postcount=9
I just trigger when Windows Updates haven't been installed for 60 days. Not as nice as having a count of outstanding updates, but I don't have time to be poking around with this. I imagine if you need a specific count, you would have to query WSUS database directly, or parse the client logs (yuk). Perhaps WMI might have something?
A quick google has revealed:
http://www.microsoft.com/technet/community/columns/scripts/sg0705.mspx#ECAA
Good luck.
I was looking for this also and found some code on Microsoft here: http://www.microsoft.com/technet/scriptcenter/scripts/sus/default.mspx?mfr=true
This code is able to get all the information on the updates (even installed). I modified it to trim and add a couple things to get the numbers needed. This could be modified further to just spit out just the number of updates, high priority, or optional. I will reply back again when I have this working as a trigger to test against the number. This should be possible to add as a userparameter and run with cscript to get the output.
Set objSearcher = CreateObject("Microsoft.Update.Searcher")
Set objResults = objSearcher.Search("IsInstalled=0")
Set colUpdates = objResults.Updates
updatesHigh = 0
updatesOptional = 0
For i = 0 to colUpdates.Count - 1
If (colUpdates.Item(i).IsInstalled = False AND colUpdates.Item(i).AutoSelectOnWebSites = False) Then
updatesOptional = updatesOptional + 1
title = "Optional Update"
ElseIf (colUpdates.Item(i).IsInstalled = False AND colUpdates.Item(i).AutoSelectOnWebSites = True) Then
updatesHigh = updatesHigh + 1
title = "High Priority Update"
End IF
Wscript.Echo title & ": " & colUpdates.Item(i).Title
Next
Wscript.Echo
Wscript.Echo "Available Updates: " & (updatesHigh + updatesOptional)
Wscript.Echo "High Priority Updates: " & updatesHigh
Wscript.Echo "Optional Updates: " & updatesOptional
Test it by running in command line as: cscript <script_file_name>
Hope this is useful to someone :)
I put this together to get me some items which show the count for available windows updates for use in triggers. You can find more information in the new thread I started at: http://www.zabbix.com/forum/showthread.php?p=49498