none
WMI Win32_QuickFixEngineering InstalledOn How can I search on this RRS feed

  • Question

  • Hi,

    I want to do a search on the objItem.InstalledOn to find any patch that has been installed on a certain date. Is this possible? I have tried and failed each time. So if we installed say 10 hot fixes this past weekend and I want to pull this from say 100 Servers is it possible??

    Monday, June 15, 2009 6:24 PM

All replies

  • Hi all!

    Solution 1:

     To get the value of all the subkeys in [HKLM\SOFTWARE\Microsoft\Updates] to report which Service Packs/Hotfixes are
    installed. (Note: Using the Registry because it contains more info than getting info from WMI). For example, The furthest I've gotten is
    [HKLM\SOFTWARE\Microsoft\Updates\Windows XP\SP2]


    CONST HKEY_LOCAL_MACHINE = &H80000002
    Dim strComputer, strKeyPath, objReg, arrSubKeys

    strComputer = "."
    strKeyPath = "SOFTWARE\Microsoft\Updates\"

    Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
    strComputer & "\root\default:StdRegProv")

    MsgBox RecurseSubKeys(HKEY_LOCAL_MACHINE, strKeyPath)

    Sub RecurseSubKeys(strHive, strKey)
    objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

    Dim arrSubKeys, strSubKey, intRC

    intRC = objReg.EnumKey(strHive, strKey, arrSubKeys)

    If intRC = 0 And IsArray(arrSubKeys) Then
    For Each strSubKey In arrSubKeys
    If Err.Number <> 0 Then
    Err.Clear
    Exit Sub
    End If
    RecurseSubKeys strHive, strKey & "\" & strSubKey
    Next
    End If
    objReg.EnumKey strHive, strKey
    End Sub
    ==================***************===================

    Solution 2:

      Hi

    The VBScript below will list updates installed regardless if Windows
    Update history exist or not, and if data exists, also the description,
    the user that installed it and installation date.

    The updates listing is obtained through the WMI class
    Win32_QuickFixEngineering.

    Put it in a text file and save it as e.g. ListHotfixes.vbs, to run it,
    double click on it or start it like this:

    wscript.exe "C:\Scripts\ListHotfixes.vbs"

    (assuming you have put the script in the folder C:\Scripts\)


    The VBScript will give this type of output:

    ------------------------------------------



    OS version: Microsoft Windows XP Professional
    SP version: Service Pack 2
    OS language: English

    Hotfixes Identified:

    HotFixID: Q282784
    Description: Windows XP Hotfix (SP1) [See Q282784 for more information]
    InstalledBy:
    InstallDate: (none found)

    HotFixID: Q282784
    Description: Windows XP Hotfix (SP1) [See Q282784 for more information]
    InstalledBy: Usr123456
    InstallDate: 10/18/2004

    ...

    ------------------------------------------


    Script start:


    '--------------------8<----------------------
    '
    ' Description: Script that outputs some computer information
    ' and lists all installed hotfixes including installation date
    '
    '

    Const OpenAsASCII      =  0
    Const OverwriteIfExist = -1

    Set oShell = CreateObject("WScript.Shell")
    Set oFSO = CreateObject("Scripting.FileSystemObject")

    sFile = oFSO.GetSpecialFolder(2).ShortPath & "\updates.txt"
    Set fFile = oFSO.CreateTextFile(sFile, OverwriteIfExist, OpenAsASCII)

    fFile.WriteLine
    fFile.WriteLine "Hotfix report date: " & Now & vbCrLf

    strComputer = "."   ' use "." for local computer

    Const HKLM = &H80000002

    'On Error Resume Next
    Set objWMIService = GetObject("winmgmts:" _
         & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    Set colSettings = objWMIService.ExecQuery _
          ("Select * from Win32_OperatingSystem")

    ' get general info about the OS

    ' Caption value for different OS:
    ' Microsoft Windows 2000 ...
    ' Microsoft Windows XP ...
    ' Microsoft(R) Windows(R) Server 2003, ..... Edition
    For Each objOperatingSystem in colSettings
       strOSCaption = objOperatingSystem.Caption
       Select Case True
         Case InStr(1, strOSCaption, "windows 2000", vbTextCompare) > 0
           strOS = "Windows 2000"
         Case InStr(1, strOSCaption, "windows xp", vbTextCompare) > 0
           strOS = "Windows XP"
         Case InStr(1, strOSCaption, "windows(r) server 2003", vbTextCompare) > 0
           strOS = "Windows Server 2003"
       End Select

       intOSLang = objOperatingSystem.OSLanguage
       strOSLangHex = Right("000" & Hex(intOSLang), 4)
       strOSServicePack = objOperatingSystem.CSDVersion
    Next

    Set objReg = GetObject("WinMgmts:{impersonationLevel=impersonate}!//" _
             & strComputer & "/root/default:StdRegProv")

    strOSLanguage = "Unknown"  ' Init value
    strKeyPath = "SOFTWARE\Classes\MIME\Database\Rfc1766"
    strValueName = strOSLangHex
    objReg.GetStringValue HKLM, strKeyPath, strValueName, strOSLanguage

    ' remove unnecessary stuff
    arrOSLanguage = Split(strOSLanguage, ";")
    strOSLanguage = arrOSLanguage(UBound(arrOSLanguage))
    If Instr(strOSLanguage, "(") > 0 Then
       arrOSLanguage = Split(strOSLanguage, "(")
       strOSLanguage = Trim(arrOSLanguage(0))
    End If

    fFile.WriteLine "OS version: " & strOSCaption
    fFile.WriteLine "SP version: " & strOSServicePack
    fFile.WriteLine "OS language: " & strOSLanguage

    ' start enumeration of hotfixes

    fFile.WriteLine vbCrLf & "Hotfixes Identified:" & vbCrLf

    strRegBaseUpdOS = "SOFTWARE\Microsoft\Updates\" & strOS
    strRegBaseUpdIE = "SOFTWARE\Microsoft\Updates\Internet Explorer 6\SP1\"

    Set colItems = objWMIService.ExecQuery _
         ("Select * from Win32_QuickFixEngineering",,48)

    For Each objItem in colItems
       If objItem.HotFixID <> "File 1" Then
         fFile.WriteLine "HotFixID: " & objItem.HotFixID
         fFile.WriteLine "Description: " & objItem.Description
         fFile.WriteLine "InstalledBy: " & objItem.InstalledBy
         strInstallDate = Null  ' init value

         If InStr(1, objItem.HotFixID, "-IE6SP1-", vbTextCompare) > 0 Then
           strRegKey = strRegBaseUpdIE & objItem.HotFixID
           objReg.GetStringValue HKLM, strRegKey, _
                  "InstalledDate", strInstallDate
         ElseIf objItem.ServicePackInEffect <> "" Then
           strRegKey = strRegBaseUpdOS & "\" & objItem.ServicePackInEffect _
                 & "\" & objItem.HotFixID
           objReg.GetStringValue HKLM, strRegKey, _
                  "InstalledDate", strInstallDate
         End If

         If IsNull(strInstallDate) Then
           strInstallDate = "(none found)"
         End If
         fFile.WriteLine "InstallDate: " & strInstallDate
         fFile.WriteLine   ' blank line
       End If
    Next

    fFile.Close
    oShell.Run sFile

    '--------------------8<----------------------

    For any other information we can check on(http://groups.google.co.uk/group/microsoft.public.win32.programmer.wmi/msg/4bfc9ed4aea3b3b3?dmode=source&hl=en)


     thnaks
     Inampudi Anil



    NOTE 1: - Disclaimer

     

    By using the following materials or sample code you agree to be bound by the license terms below and the Microsoft Partner Program Agreement the terms of which are incorporated herein by this reference. These license terms are an agreement between Microsoft Corporation (or, if applicable based on where you are located, on of its affiliates) and you. Any materials (other than sample code) we provide to you are for your internal use only. Any sample code is provided for the purpose of illustration only and is not intended to be used in a production environment. We grant you a nonexclusive, royalty-free right to use and modify the sample code and to reproduce and distribute the object code form of the sample code, provided that you agree: (i) to not use Microsoft's name, logo, or trademarks to market your software produced in which the sample code is embedded; (ii) to include a valid copyright notice on your software product in which the sample code is embedded; (iii) to provide on behalf of and for the benefit of your subcontractors a disclaimer of warranties, exclusion of liability for indirect and consequential damages and a responsible limitation of liability; and (iv) to indemnify, hold harmless, and defend Microsoft, its affiliates and suppliers from and against any third party claims or lawsuits, including attorney's fees, that arise or result from the use or distribution of the sample code.

    -----


    NOTE 2: - Disclaimer

    The links in this message may lead to third-party Web sites. Microsoft provides third-party resources to help you find customer service and/or technical support resources. Information at these sites may change without notice. Microsoft is not responsible for the content at any third-party Web sites and does not guarantee the accuracy of third-party information.


    • Proposed as answer by Anil Inampudi Monday, August 17, 2009 12:12 PM
    Tuesday, August 11, 2009 4:38 PM