Tuesday, August 22, 2017

Update detection


From time to time you may need to check the updates installed on a target client.

Here's a couple of articles which discuss the method of doing this
http://www.alexandreviot.net/2014/10/03/configmgr-2012-application-detection-method-for-software-update/

https://stackoverflow.com/questions/9347985/how-to-read-installed-updates-view-installed-updates-from-registry-on-vista-or

below is a modified version of the scripts to exit with a 0 for success or 1 for fail (not present)

'Returns if Windows KB2758857 installed
Option Explicit
Dim objWMI, strComputer
strComputer = "."

'Run the query
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &strComputer& "\root\cimv2")

Dim listPatches
Dim patch
Set listPatches = objWMI.ExecQuery ("Select * from win32_QuickFixEngineering where HotFixID like 'KB2758857'")

For Each patch in listPatches

If patch.HotFixID = "KB2758857" then

'Update found. Exit loop here with 0
'wscript.echo patch.HotFixID

wscript.quit 0

End If

Next

'List checked but patch not found. Exit with 1
WScript.Quit 1