none
Win32_PnPSignedDriver Diles to add to SMS_DEF.MOF

    Question

  • Hi ,

    I a trying to add the "Win32_PnPSignedDriver" since I want to collect the driver version from the class.

    I am keep getting the below failure on each attribute I am trying to add from this class:Failed to add an instance of class

    "Failed to add an instance of class Win32_PnPSignedDriver to historical store: 80041002 InventoryAgent 1/24/2011 9:33:45 PM 5248 (0x1480)"

    When I was looking for a sloution I have found that the problem might be that the key of the class is not valid since it is not holding any data(NULL) , the key of the class is the "Name" field.

    Any suggestions would be appreciated

    Monday, January 24, 2011 8:03 PM

Answers

  • Hi ,

    Pay Attention - MS recomending not to use this class!!!! they are saying the the data in this class  can not ne trusted and they are consdiering even to remove the class.

    In case you do want to collect from this class  , see below script that querying the class and creating a MIF file with the collected data:

    set fso = createobject("scripting.filesystemobject")
    set wshShell = createobject("wscript.shell")
    targetdir = wshShell.regread("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\SMS\Client\Configuration\Client Properties\NOIDMIF Directory")

    set targetmif = fso.createtextfile(targetdir & "\pnpinfo.mif",true)

    Const wbemFlagReturnImmediately = &h10
    Const wbemFlagForwardOnly = &h20

     
       Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
       Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PnPSignedDriver", "WQL", _
                                              wbemFlagReturnImmediately + wbemFlagForwardOnly)


    'Write Mif header
    targetmif.writeline("Start Component")
    targetmif.writeline(" NAME = ""WORKSTATION""")


    i = 1
    For Each objItem In colItems
     'Write group header
     targetmif.writeline(" Start Group")
     targetmif.writeline("  NAME = ""System Drivers""")
     targetmif.writeline("  ID = " & i)
     targetmif.writeline("  CLASS = ""System|Signed_Drivers|1.0""")
     targetmif.writeline("  KEY = 1")
     
     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""Description""")
     targetmif.writeline("   ID = 1")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.Description) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.Description,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""DeviceClass""")
     targetmif.writeline("   ID = 2")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.DeviceClass) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.DeviceClass,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""DeviceID""")
     targetmif.writeline("   ID = 3")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.DeviceID) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.DeviceID,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""DeviceName""")
     targetmif.writeline("   ID = 4")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.DeviceName) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.DeviceName,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""DriverDate""")
     targetmif.writeline("   ID = 5")
     targetmif.writeline("   TYPE = STRING(128)")
     if objItem.DriverDate <> "" then
      targetmif.writeline("   VALUE = """ & WMIDateStringToDate(objItem.DriverDate) & """")
     else
      targetmif.writeline("   VALUE = """ & "unknown" & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""DriverProviderName""")
     targetmif.writeline("   ID = 6")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.DriverProviderName) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.DriverProviderName,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""DriverVersion""")
     targetmif.writeline("   ID = 7")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.DriverVersion) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.DriverVersion,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""HardWareID""")
     targetmif.writeline("   ID = 8")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.HardWareID) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.HardWareID,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""InfName""")
     targetmif.writeline("   ID = 9")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.InfName) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.InfName,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""IsSigned""")
     targetmif.writeline("   ID = 10")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.IsSigned) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.IsSigned,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""Location""")
     targetmif.writeline("   ID = 11")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.Location) then
      targetmif.writeline("   VALUE = """"")
     else 
      targetmif.writeline("   VALUE = """ & replace(objItem.Location,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""Manufacturer""")
     targetmif.writeline("   ID = 12")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.Manufacturer) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.Manufacturer,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     'Finish group
     targetmif.writeline(" End Group")

     i = i + 1
    Next

     


    'Finish Mif
    targetmif.writeline("End Component")

     

    Function WMIDateStringToDate(dtmDate)
    WScript.Echo dtm:
     WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
     Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
     & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
    End Function

    Sunday, February 13, 2011 8:39 AM

All replies

  • You could try (in a lab environment of course, right?)  :)  telling the sms_def.mof snippet that an attribute, like 'description' is a ,key ... even though it isn't.
    Standardize. Simplify. Automate.
    Monday, January 24, 2011 8:08 PM
    Moderator
  • Try that , it is not working , getting the same error

    I have tried the below but it is not working as well

    Configuration.mof:

    //--------------------------------------------
    // PnP_Driver_Details
    //--------------------------------------------
    #pragma namespace("\\\\.\\root\\cimv2")

    [Union,ViewSources{"select DeviceName,Description,FriendlyName,DeviceID,DriverName,DriverVersion,HardWareID from Win32_PnPSignedDriver"},ViewSpaces{"\\\\.\\root\\cimv2"},
    dynamic,Provider("MS_VIEW_INSTANCE_PROVIDER")]
    class PNP_SIGNED_DRIVER
    {
     [PropertySources{"DeviceName"}] String DeviceName;
     [PropertySources{"Description"}] String Description;
     [PropertySources{"FriendlyName"}] String FriendlyName;
     [PropertySources{"DeviceID"},key] string DeviceID;
     [PropertySources{"DriverName"}] String DriverName;
     [PropertySources{"DriverVersion"}] String DriverVersion;
     [PropertySources{"HardWareID"}] String HardWareID;
    };

    SMS_DEF.MOF:

    // **************************************
    #pragma namespace ("\\\\.\\root\\cimv2\\SMS")
    [ SMS_Report     (True),
      SMS_Group_Name ("PNP SIGNED DRIVER"),
      SMS_Class_ID   ("CUSTOM|PNP_SIGNED_DRIVER|1.0") ]

    class PNP_SIGNED_DRIVER : SMS_Class_Template
    {
     [SMS_Report (TRUE)] string DeviceName;
     [SMS_Report (TRUE)] string Description;
     [SMS_Report (TRUE)] string FriendlyName;
     [SMS_Report(TRUE),key] string DeviceID;
     [SMS_Report (TRUE)] string DriverName;
     [SMS_Report (TRUE)] string DriverVersion;
     [SMS_Report (TRUE)] string HardWareID;
    };

    The class is being created on the clients but ni instances are being created , it that there is a conflict between the key and in the originial class and th class is being created.

     

    Tuesday, January 25, 2011 12:59 PM
  • I suspect that class is a type that can't be queried w/sms_def.mof.  If you look at the mof syntax itself, it says "toinstance tosubclass"

    Other wmi classes which can be inventoried (like win32_physicalmedia, etc.), just have "tosubclass" in the mof defition of the class properties.  So... I'm thinking you're out of luck.

    But this is just a guess.  You might want to open up a support call with Microsoft, and see if they can explain why/why not it doesn't work.

    A *potential* trick.  There's plenty of times I haven't been able to do a direct mof edit.  So... I cheat, and run a recurring script (like a weekly advertisement) which parses through the data, and dumps it into a custom regkeys or custom WMI namespace.  and then I inventory *that*.  Local Group Members is an example.  So... if you have the time and the inclination, you could craft something like that; a script + mof edit.


    Standardize. Simplify. Automate.
    Tuesday, January 25, 2011 6:12 PM
    Moderator
  • Thansk for the answer ,

    I am trying to avoid scripting solution but I guess somtime iy has to to go to it.

    BTW , do you any other solution to collect PnP devices driver version data?

    One more inventory Q , I am getting some requirmenst related to collect data in a specific line in a file.

    Did you ever did domething like that? , I was thinking about using DCM scripts

    Thanks 

    Tuesday, January 25, 2011 7:32 PM
  • pnp:  I was assuming you were trying the signed driver because it had info inside it that the default sms_def.mof (but by default disabled) class of Win32_PnpEntity didn't provide the information you needed.  Have you tried enabling that class, and oh.. probably the attribs of DeviceID and Name?  I think that might have SOME of what you are looking for.

    Specific line in a file:  I can think of 2, sorta 3 ways to do this.

    1) I'd DCM, if I could: Assuming that what they aren't asking for is a "specific line in the file", but what they really want to know is "is line 53 in this file = 'This text'", then I'd use a DCM.  It would likely need to be a vbscripted test.  i.e., you'd have the applicable be whether or not the file exists at all, and the test be to parse thru the file, and confirm line 53.  Then wscript.echo "Something".  and test for that.

    2) If you can't DCM, i.e., the line they want to know about could be any number of results, and all of them are perfectly valid results... then either...

      2a) vbscript a DCM, where all it does is read through that file, and regwrite it to a custom regkey.  Then RegkeyToMof that into a custom MOF.

      2b) Instead of the vbscript in DCM, the vbscript is a recurring advert, and it reads thru the file, and regwrite it to a custom regkey.  same RegKeytoMof to a custom mof.

    PS: If you DO get a scripted method for PNPSignedDriver, let me know.  There was some rumblings internally here where a group wanted to know the results of     select description from win32_pnpsigneddriver where deviceclass='hdc'     But it was more of a "can you", internally, not a "you have to make it happen" request.  So I haven't tested anything out in the lab yet.  But if you're going to do all the legwork... I have no problems stealing your code.  :-)


    Standardize. Simplify. Automate.
    Tuesday, January 25, 2011 9:08 PM
    Moderator
  • Hi ,

    Reagrding the PnPEntity  , it doesn't have attribure for driver version.

    I pormise to publish here solution/code for the signed driver once I have it.

    Thanks for everything

    Wednesday, January 26, 2011 11:35 AM
  • Hi ,

    Pay Attention - MS recomending not to use this class!!!! they are saying the the data in this class  can not ne trusted and they are consdiering even to remove the class.

    In case you do want to collect from this class  , see below script that querying the class and creating a MIF file with the collected data:

    set fso = createobject("scripting.filesystemobject")
    set wshShell = createobject("wscript.shell")
    targetdir = wshShell.regread("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\SMS\Client\Configuration\Client Properties\NOIDMIF Directory")

    set targetmif = fso.createtextfile(targetdir & "\pnpinfo.mif",true)

    Const wbemFlagReturnImmediately = &h10
    Const wbemFlagForwardOnly = &h20

     
       Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
       Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PnPSignedDriver", "WQL", _
                                              wbemFlagReturnImmediately + wbemFlagForwardOnly)


    'Write Mif header
    targetmif.writeline("Start Component")
    targetmif.writeline(" NAME = ""WORKSTATION""")


    i = 1
    For Each objItem In colItems
     'Write group header
     targetmif.writeline(" Start Group")
     targetmif.writeline("  NAME = ""System Drivers""")
     targetmif.writeline("  ID = " & i)
     targetmif.writeline("  CLASS = ""System|Signed_Drivers|1.0""")
     targetmif.writeline("  KEY = 1")
     
     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""Description""")
     targetmif.writeline("   ID = 1")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.Description) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.Description,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""DeviceClass""")
     targetmif.writeline("   ID = 2")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.DeviceClass) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.DeviceClass,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""DeviceID""")
     targetmif.writeline("   ID = 3")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.DeviceID) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.DeviceID,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""DeviceName""")
     targetmif.writeline("   ID = 4")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.DeviceName) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.DeviceName,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""DriverDate""")
     targetmif.writeline("   ID = 5")
     targetmif.writeline("   TYPE = STRING(128)")
     if objItem.DriverDate <> "" then
      targetmif.writeline("   VALUE = """ & WMIDateStringToDate(objItem.DriverDate) & """")
     else
      targetmif.writeline("   VALUE = """ & "unknown" & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""DriverProviderName""")
     targetmif.writeline("   ID = 6")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.DriverProviderName) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.DriverProviderName,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""DriverVersion""")
     targetmif.writeline("   ID = 7")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.DriverVersion) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.DriverVersion,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""HardWareID""")
     targetmif.writeline("   ID = 8")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.HardWareID) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.HardWareID,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""InfName""")
     targetmif.writeline("   ID = 9")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.InfName) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.InfName,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""IsSigned""")
     targetmif.writeline("   ID = 10")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.IsSigned) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.IsSigned,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""Location""")
     targetmif.writeline("   ID = 11")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.Location) then
      targetmif.writeline("   VALUE = """"")
     else 
      targetmif.writeline("   VALUE = """ & replace(objItem.Location,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     targetmif.writeline("  Start Attribute")
     targetmif.writeline("   NAME = ""Manufacturer""")
     targetmif.writeline("   ID = 12")
     targetmif.writeline("   TYPE = STRING(128)")
     if isnull(objItem.Manufacturer) then
      targetmif.writeline("   VALUE = """"")
     else
      targetmif.writeline("   VALUE = """ & replace(objItem.Manufacturer,"\","\\") & """")
     end if
     targetmif.writeline("  End Attribute")

     'Finish group
     targetmif.writeline(" End Group")

     i = i + 1
    Next

     


    'Finish Mif
    targetmif.writeline("End Component")

     

    Function WMIDateStringToDate(dtmDate)
    WScript.Echo dtm:
     WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
     Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
     & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
    End Function

    Sunday, February 13, 2011 8:39 AM
  • Very nice. Personally, I'm not a fan of noidmif files. If I were tasked to pull in that information, I'd re-write that script to instead dump into a custom wmi namespace, and extend sms_def.mof. But that's me. If it works for you, great!
    Standardize. Simplify. Automate.
    Sunday, February 13, 2011 1:14 PM
    Moderator
  • Hi All ,

    Since most of us don't work with NO ID MIFs anymore see below script which quering the Win32_PnPSignedDriver and created new healthy class which can be inventoried

     

    wbemCimtypeString = 8
    wbemCimtypeDatetime = 101
    strComputer = "."
    ClassName = "Win32_PnPSignedDriver"
    NewClassName = "CustomSignedDriver"
    ' 1. Query Win32_PnPSignedDriver for needed fields/attributes
    QueryStr = "SELECT DeviceName,FriendlyName,DeviceID,HardWareID,Description,DriverName,DriverDate,InstallDate,DriverVersion FROM " & ClassName  & " where DriverVersion is not null"
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    Set colItems1 = objWMIService.ExecQuery(QueryStr,,48)
    For Each objItem in colItems1
     NumOfDrivers = NumOfDrivers +1
        Wscript.Echo "-------------------------------------"
        Wscript.Echo "Win32_PnPSignedDriver instance # " & NumOfDrivers
        Wscript.Echo "-------------------------------------"
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "DeviceID: " & objItem.DeviceID
        Wscript.Echo "DeviceName: " & objItem.DeviceName
        Wscript.Echo "DriverDate: " & objItem.DriverDate
        Wscript.Echo "DriverName: " & objItem.DriverName
        Wscript.Echo "DriverVersion: " & objItem.DriverVersion
        Wscript.Echo "FriendlyName: " & objItem.FriendlyName
        Wscript.Echo "HardWareID: " & objItem.HardWareID
        Wscript.Echo "InstallDate: " & objItem.InstallDate
     
    Next
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "NumOfDrivers = " & NumOfDrivers
    ' Now colItems1 holds all the instances of Win32_PnPSignedDriver
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' 2. Create new WMI class under same path(Root\CIMV2)  , under this class we will create instances with the above query data
    ' Check if the class already exists
    exists = False
    For Each objClas in objWMIService.SubclassesOf()
     if( objClas.Path_.Class = "CustomSignedDriver") then
      exists = True
      Wscript.Echo "CustomSignedDriver class already exists, no need to create it"
      exit for
     end if
    next

    if(exists = False) then
     ' Class doesn't exist, create it
     Set objSWbemService = GetObject("Winmgmts:root\cimv2")
     Set objClass = objSWbemService.Get()
     ' Name it
     objClass.Path_.Class = "CustomSignedDriver"
     ' Add a property , String property
     objClass.Properties_.add "DeviceName", wbemCimtypeString 
     objClass.Properties_.add "FriendlyName", wbemCimtypeString 
     objClass.Properties_.add "DeviceID", wbemCimtypeString 
     objClass.Properties_.add "HardWareID", wbemCimtypeString 
     objClass.Properties_.add "Description", wbemCimtypeString 
     objClass.Properties_.add "DriverName", wbemCimtypeString 
     objClass.Properties_.add "DriverDate", wbemCimtypeDatetime 
     objClass.Properties_.add "InstallDate", wbemCimtypeDatetime 
     objClass.Properties_.add "DriverVersion", wbemCimtypeString 
     ' Make the property a key property
     objClass.Properties_("DeviceID").Qualifiers_.add "key", true
     ' Write the new class to the root\default namespace in the repository
     Set objClassPath = objClass.Put_
     exists = True
     WScript.Echo objClassPath.Path
     Wscript.Echo "Test after trying to create a new class if exists = " & exists ' TEST after creating the class
    else
     ' Class already exists, delete old instnces
     Set colItems2 = objWMIService.ExecQuery ("select * from CustomSignedDriver")
     For each item in colItems2
      item.Delete_
     Next
     WScript.Echo "All the old instances were deleted"
     Wscript.Echo "-----------------------------------"
     Wscript.Echo "-----------------------------------"
    end if

    'Create an instance of the new class using SWbemObject.SpawnInstance
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    Set colItems1 = objWMIService.ExecQuery(QueryStr,,48)
    For Each objItem in colItems1
     Set objNewInst = GetObject( _
      "Winmgmts:root\cimv2:CustomSignedDriver").Spawninstance_
      objNewInst.DeviceName = objItem.DeviceName
      objNewInst.FriendlyName = objItem.FriendlyName
      objNewInst.DeviceID = objItem.DeviceID
      objNewInst.HardWareID = objItem.HardWareID
      objNewInst.Description = objItem.Description
      objNewInst.DriverName = objItem.DriverName
      objNewInst.DriverDate = objItem.DriverDate
      objNewInst.InstallDate = objItem.InstallDate
      objNewInst.DriverVersion = objItem.DriverVersion
     ' Write the instance into the repository
     Set objInstancePath = objNewInst.Put_
    Next

    Set colItems2 = objWMIService.ExecQuery ("select * from CustomSignedDriver")
     Wscript.Echo "Devices ID:"
     Wscript.Echo "------------- "
     num = 1
    For each item in colItems2
     Wscript.Echo "Device # " & num & " ID: " & item.DeviceID
     num = num + 1
    Next

     

    Wednesday, April 27, 2011 1:01 PM
  • Did they say what they mean by that?

    To not damage the machine?
    To not list the correct versions?

    I ask as Hey Script Guy recommended it here: 

    http://blogs.technet.com/b/heyscriptingguy/archive/2006/03/20/how-can-i-get-a-list-of-installed-device-drivers.aspx

    Monday, March 04, 2013 3:18 AM
  • Hello EASULIN , i have used your vbscript to create the custom class and have added it to my inventory on my client settings ,great it works in creating the custom class  , when the  2012 client runs the inventory , in the inventoryagent.log i get -

    Collection: Namespace = root\cimv2; Query = SELECT __CLASS, __PATH, __RELPATH, DeviceID, Description, DeviceName, DriverDate, DriverName, DriverVersion, FriendlyName, HardWareID, InstallDate FROM Win32_PnPSignedDriverCustom; Timeout = 600 secs.

    so I assume that the class is being quirered , however no data is being collected , I can get the data from the machine using get-wmobject and I can trace the inventory xml files in the temp directory but they have nothing in them about this class.

    Any Ideas on how to troubleshoot ?

    many thanks Dene

    Friday, September 27, 2013 3:15 AM