Answered Inventory custom registry key via mof file

  • martedì 8 maggio 2012 15:29
     
     

    Hi have been asked to start inventorying our COE version, which we have created a registry key during our build. I am trying to capture this information in the config and sms_def mof.

    In the config mof I added the below:

    [DYNPROPS]
    Class COE_Version
    {
     [key]
     string keyname;
     string  Version;
    };

    [DYNPROPS]
    instance of COE_Version
    {
       keyname = "COE";
       [PropertyContext("local|HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432NODE\\Company\\COE|Version"), Dynamic, Provider("RegPropProv")] Version;
    };

    In the sms def mof I added this:

    [  SMS_Report (True),
       SMS_Group_Name  ("COE Version"),
       SMS_Class_ID    ("Custom|COE_Version|1.0")]

       class COE_Version : SMS_Class_Template
    {
     [SMS_Report (True), KEY] String keyname;
     [SMS_Report (TRUE)] String Version;
    };

    After kicking a policy and hardware inventory on several clients I do see that the table is created in the database on this new class. When I look in resource explorer for this client I see the attached image. I do not see the Version being populated.

    Here is what the registry key looks like:

    Is my syntax wrong? I have also ran a full hardware inventory and still same thing. Thanks

Tutte le risposte

  • martedì 8 maggio 2012 16:56
    Moderatore
     
     Con risposta

    Why not use the RegkeytoMOF program to create the mof edits for you.

    http://myitforum.com/cs2/files/folders/proddocs/entry152945.aspx


    http://www.enhansoft.com/

  • martedì 8 maggio 2012 19:38
     
     

    Hi thanks for your reply

    Thanks for the link. I deleted my edits and added what the tool gave me and still seeing the same issue.

    When looking in the database I dont see the "Version" column added.

    Still seeing the same in resource explorer as well, the Version is not being inventoried.

  • martedì 8 maggio 2012 20:39
    Moderatore
     
     
    what does the mof edit look like?

    http://www.enhansoft.com/

  • martedì 8 maggio 2012 21:29
     
     

    here is the configuration mof:

    #pragma namespace ("\\\\.\\root\\cimv2")
    #pragma deleteclass("COEVersion", NOFAIL)
    [DYNPROPS]
    Class COEVersion
    {
     [key] string KeyName;
     String Version;
    };

    [DYNPROPS]
    Instance of COEVersion
    {
     KeyName="RegKeyToMOF_32";
     [PropertyContext("Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Company\\COE|Version"),Dynamic,Provider("RegPropProv")] Version;
    };

    This is the sms_def.mof:

    #pragma namespace ("\\\\.\\root\\cimv2\\SMS")
    #pragma deleteclass("COEVersion", NOFAIL)
    [SMS_Report(TRUE),
    SMS_Group_Name("COEVersion"),
    SMS_Class_ID("Custom|COEVersion|1.0")]
    Class COEVersion: SMS_Class_Template
    {
    [SMS_Report(TRUE),key] string KeyName;
    [SMS_Report(TRUE)] String Version;
    };

  • martedì 8 maggio 2012 21:35
    Moderatore
     
     
    There should be more too it than that, Where is the 64 bit data? Did you unselect the check box when you create the mof edit?

    http://www.enhansoft.com/

  • martedì 8 maggio 2012 22:45
    Moderatore
     
     

    I suspect it's because cm07 is 32bit, and you are trying to get info directly out of the 32-bit redirected space.  Do this.  Still use regkeytomof, but...

    temporarily, on the machine from which you launch regkeytomof, recreate all of the keys in hklm\software\coe; just so that regkeytomof and select the keys from that location.  use regkeytomof to build your edit from hklm\software\coe, NOT hklm\software\wow6432bit\coe,; copy/paste that result into your mof files.

    Should be better now. (once you've proven that to yourself, you can delete the temporary keys in the registry)

    Also, I'm not sure if you want to check one of the checkboxes you are checking; I think you just want the direct version, not "all subkeys of coe / version".


    Standardize. Simplify. Automate.

  • mercoledì 9 maggio 2012 18:16
     
     

    Hi Sherry thanks for replying

    I did as you suggested and I dont see the information in wmi. Here is the edits I added

    Config mof:

    #pragma namespace ("\\\\.\\root\\cimv2")
    #pragma deleteclass("COEVersion", NOFAIL)
    [DYNPROPS]
    Class COEVersion
    {
    [key] string KeyName;
    String Version;
    };

    [DYNPROPS]
    Instance of COEVersion
    {
    KeyName="COE";
    [PropertyContext("Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\CBR\\COE|Version"),Dynamic,Provider("RegPropProv")] Version;
    };

    sms_def mof:

    #pragma namespace ("\\\\.\\root\\cimv2\\SMS")
    #pragma deleteclass("COEVersion", NOFAIL)
    [SMS_Report(FALSE),SMS_Group_Name("COEVersion"),SMS_Class_ID("Custom|COEVersion|1.0")]
    Class COEVersion: SMS_Class_Template
    {
    [SMS_Report(FALSE),key] string KeyName;
    [SMS_Report(TRUE)] String Version;
    };

    I see this in WMI. The Version is not being populated.

    So on the computer where I created the dummy registry key under Software\COE... I left the key there and kicked hardware inventory on that computer and that worked. Resource Explorer is showing the Version.

    In your tool what is the "Enable 64bits" check box used for?

    Thanks Yamini

  • mercoledì 9 maggio 2012 22:56
    Moderatore
     
     

    look at the sms_def.mof snippet.

    see the lines for (in one section)

    SMS_Context_1("__ProviderArchitecture=32|uint32")

    and in the other section:

    SMS_Context_1("__ProviderArchitecture=64|uint32"),

    You Do, absolutely, want both sections in sms_def.mof.  Now, the trick is... ConfigMgr07, the Client, is 32-bit only.  So... by default inventory will ONLY look in the 32-bit section of the registry, unless you play the game right, and make the mof edits perfectly.  irritating, I know.  But that's just what we have to do, because we all have to support both 32 and 64 bit OS', using a 32-bit only client.

    Under CM12 it will be even MORE important to have both sections; it gets a little more complex for regkey inventory when we have 32-bit clients on 32-bit machines, and 64-bit clients on 64-bit machines... but we still have 32-bit apps installing onto 64-bit clients.  As long as you use regkeytomof, and there aren't any references to wow6432bit in your mof snippets, it'll be fine.

    Oh, and regkeytomof isn't mine--thank Mark Cochrane!  I ask him for tweaks and fixes--but he's the genius.  :)


    Standardize. Simplify. Automate.

  • mercoledì 9 maggio 2012 22:57
    Moderatore
     
     

    oh, and another thing--the version is showing from your wow6432node space.  Go ahead and delete it from the hklm\software\coe, and do a full hinv.  You'll see.


    Standardize. Simplify. Automate.

  • giovedì 10 maggio 2012 14:05
     
     

    Hi Sherry

    I started over and added the below to my mofs. I manually created the key again and used the regkeytomof tool

    Config mof:

    #pragma namespace ("\\\\.\\root\\cimv2")
    #pragma deleteclass("COE_Version", NOFAIL)
    [DYNPROPS]
    Class COE_Version
    {
    [key] string KeyName;
    String Version;
    };

    [DYNPROPS]
    Instance of COE_Version
    {
    KeyName="COE";
    [PropertyContext("Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\CBR\\COE|Version"),Dynamic,Provider("RegPropProv")] Version;
    };

    #pragma namespace ("\\\\.\\root\\cimv2")
    #pragma deleteclass("COE_Version_64", NOFAIL)
    [DYNPROPS]
    Class COE_Version_64
    {
    [key] string KeyName;
    String Version;
    };

    [DYNPROPS]
    Instance of COE_Version_64
    {
    KeyName="COE";
    [PropertyContext("Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\KBR\\COE|Version"),Dynamic,Provider("RegPropProv")] Version;
    };

    SMS def mof:

    #pragma namespace ("\\\\.\\root\\cimv2\\SMS")
    #pragma deleteclass("COE_Version", NOFAIL)
    [SMS_Report(FALSE),SMS_Group_Name("COE_Version"),SMS_Class_ID("Custom|COE_Version|1.0"),
    SMS_Context_1("__ProviderArchitecture=32|uint32"),
    SMS_Context_2("__RequiredArchitecture=true|boolean")]
    Class COE_Version: SMS_Class_Template
    {
    [SMS_Report(TRUE),key] string KeyName;
    [SMS_Report(TRUE)] String Version;
    };

    #pragma namespace ("\\\\.\\root\\cimv2\\SMS")
    #pragma deleteclass("COE_Version_64", NOFAIL)
    [SMS_Report(FALSE),SMS_Group_Name("COE_Version"),SMS_Class_ID("Custom|COE_Version|1.0"),
    SMS_Context_1("__ProviderArchitecture=64|uint32"),
    SMS_Context_2("__RequiredArchitecture=true|boolean")]
    Class COE_Version_64 : SMS_Class_Template
    {
    [SMS_Report(TRUE),key] string KeyName;
    [SMS_Report(TRUE)] String Version;
    };

    Still no luck. I tested on a new computer (not the source computer with the dummy key) and WMI is not populated with the version. I kicked inventory and the inventoryagent log does not have anything about the COE version. I kicked a full hardware inventory as well.

    Registy key on this computer is here: HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432NODE\\CBR\\COE|Version

    Not sure what I am doing wrong, feel like I am missing something obvious.

    Thanks Yamini

  • giovedì 10 maggio 2012 16:53
    Moderatore
     
     

    Is this a typo?  if not, this is why:

    a) Registy key on this computer is here: HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432NODE\\CBR\\COE|Version

    b) configuration.mof isn't looking in CBR, it's looking in KBR:  Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\KBR\\COE|Version


    Standardize. Simplify. Automate.

  • giovedì 10 maggio 2012 17:44
     
     

    Sorry typo in the post but the mof is correct.

    #pragma namespace ("\\\\.\\root\\cimv2")
    #pragma deleteclass("COE_Version", NOFAIL)
    [DYNPROPS]
    Class COE_Version
    {
    [key] string KeyName;
    String Version;
    };

    [DYNPROPS]
    Instance of COE_Version
    {
    KeyName="COE";
    [PropertyContext("Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\KBR\\COE|Version"),Dynamic,Provider("RegPropProv")] Version;
    };

    #pragma namespace ("\\\\.\\root\\cimv2")
    #pragma deleteclass("COE_Version_64", NOFAIL)
    [DYNPROPS]
    Class COE_Version_64
    {
    [key] string KeyName;
    String Version;
    };

    [DYNPROPS]
    Instance of COE_Version_64
    {
    KeyName="COE";
    [PropertyContext("Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\KBR\\COE|Version"),Dynamic,Provider("RegPropProv")] Version;
    };

  • giovedì 10 maggio 2012 18:47
    Moderatore
     
     Con risposta

    All I can think of that is left is that in RegkeytoMof... you are apparently checking the box for dynamic instances.  I'm guessing you actually don't want that.  Go back into regkeytomof, and UNcheck the box (well, make sure you do NOT check the box, it is not checked by default) about dynamic instances.  Of course, leave the box checked about 64bit. 

    Either that, are you are looking at the wrong "root" for the dynamic, and you really want to be on KBR, not COE, when you build the dynamic.  But I'm 90% sure that all you really want is the not-dynamic.


    Standardize. Simplify. Automate.