Client Management Suite

 View Only
  • 1.  custom inventory registry help

    Posted Nov 09, 2011 06:45 AM

    Hi guys,

    this is my first attempt at making custom inventory in ns7....

    i was using this article as a reference ( https://www-secure.symantec.com/connect/articles/custom-inventory-solution-7-script-examples )

    what i'm trying to do is query the "font" information in the registry and let that populate that into the altiris database.

    I think i'm going wrong with the creation of my data class ( screenshot attached)

    and with my script ( it fails on line 45)

    Can anyone have a look and see if i'm on the right path....

    script:

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    'Gather registry key value from machine and posting data to NS using Altiris NSE Component
    '===================================================================================================================
    '      On Error Resume Next

    const HKEY_CURRENT_USER = &H80000002

    strComputer = "."
    Set oReg=GetObject( _
       "winmgmts:{impersonationLevel=impersonate}!\\" &_
        strComputer & "\root\default:StdRegProv")
    strKeyPath = "Software\Microsoft\Office\9.0\Excel\Options"
    strValueName1 = "Font"
    oReg.GetStringValue _
       HKEY_LOCAL_MACHINE,strKeyPath,strValueName1,stringfont

    'WScript.Echo "Font: " & stringfont

    if isnull(stringfont) then
      stringrequestid = "missing"
    end if


    '===================================================================================================================

    'Create instance of Altiris NSE component
    dim nse
    set nse = WScript.CreateObject ("Altiris.AeXNSEvent")

    ' Set the header data of the NSE
    ' Please don't modify this GUID
    nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"
    nse.Priority = 1

    'Create Inventory data block. Here assumption is that the data class with below guid is already configured on server
    dim objDCInstance
    set objDCInstance = nse.AddDataClass ("{e401a979-4799-4053-9fbc-e2726d7335b6}")

    dim objDataClass
    set objDataClass = nse.AddDataBlock (objDCInstance)

    'Add a new row
    dim objDataRow
    set objDataRow = objDataClass.AddRow
    'Set columns
    objDataRow.SetField 0, stringfont

    nse.SendQueued



  • 2.  RE: custom inventory registry help

    Posted Nov 09, 2011 10:09 AM

    First - I highly recommend you change that data class name.  SMP prefaces custom inventory tables with INV.  This means your custom data class table is named "Inv_Font" in the database.  That is dangerously close to the built-in Inv_Fonts table used by Inventory Solution.

    Get rid of the DeviceID from the data class.  SMP automatically adds the guid of the computer to custom inventory tables for you.  You don't need to put anything in your dataclass for this - it's a freebie.

    The DeviceID is also messing you up in the CI script; you have DeviceID as a required field in your dataclass - but you don't collect anything for that variable, or write that to your Output for the inventory.  You are only writing stringfont.

    According to your dataclass you would need to change your set columns section:

    objDataRow.SetField 0, DeviceID

    objDataRow.SetField 1, stringfont

    Next you have a variable in your script that isn't used:

    if isnull(stringfont) then
      stringrequestid = "missing"
    end if

    I would change stringrequestid to your stringfont variable, or even get rid of it entirely.  A Null value is perfectly acceptable in the database in any data type, if I remember correctly.

    You are using the hex for Hkey_Local_Machine, but assigning HKey_Current_User as the constant name.

    HKCU is actually &H80000001 (referenced from http://www.aspfree.com/c/a/Windows-Scripting/Working-with-the-Windows-Registry-in-WSH/ )

                &H80000000     HKEY_CLASSES_ROOT
    
                &H80000001     HKEY_CURRENT_USER
    
                &H80000002     HKEY_LOCAL_MACHINE
    
                &H80000003     HKEY_USERS
    
                &H80000005     HKEY_CURRENT_CONFIG

    In your WMI query, you don't need to set strComputer to a period.  Just use the period in your WMI connect string.  They use this in examples, but it's just busywork.  The only time I use strComputer in the WMI connect string is if I need to loop through and change this variable.  Here's top part of your script, modified:

    Const HKEY_CURRENT_USER = &H80000001 'corrected hex value to match constant name

    strComputer = "."
    Set oReg=GetObject( _
       "winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
    strKeyPath = "Software\Microsoft\Office\9.0\Excel\Options"
    strValueName1 = "Font"
    oReg.GetStringValue _
       HKEY_LOCAL_MACHINE,strKeyPath,strValueName1,stringfont

    ' everything in the top portion of your vbs below this point is extraneous...

    If you have any questions, reply to this post.  Good luck.



  • 3.  RE: custom inventory registry help

    Posted Nov 10, 2011 06:02 AM

    Thanks so much for the advise man.

     

    I'm gonna give it a whirl, and tell you how it goes



  • 4.  RE: custom inventory registry help

    Posted Nov 17, 2011 07:48 AM

    This is what my script looks like now....

    I still get an error though ( screenshot attached)

    I also added a screenshot of the dataclass; took out the device id.

    I can basically read what the scrip is doing, but what i don't understand is the "stringfont" what is it exactly... is it a function or a reference, i'm not understanding that.

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    'Gather registry key value from machine and posting data to NS using Altiris NSE Component
    '===================================================================================================================
    '      On Error Resume Next

    Const HKEY_CURRENT_USER = &H80000001

    strComputer = "."
    Set oReg=GetObject( _
       "winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
    strKeyPath = "Software\Microsoft\Office\9.0\Excel\Options"
    strValueName1 = "Font"
    oReg.GetStringValue _
       HKEY_CURRENT_USER,strKeyPath,strValueName1,stringfont


    '===================================================================================================================

    'Create instance of Altiris NSE component
    dim nse
    set nse = WScript.CreateObject ("Altiris.AeXNSEvent")

    ' Set the header data of the NSE
    ' Please don't modify this GUID
    nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"
    nse.Priority = 1

    'Create Inventory data block. Here assumption is that the data class with below guid is already configured on server
    dim objDCInstance
    set objDCInstance = nse.AddDataClass ("{e401a979-4799-4053-9fbc-e2726d7335b6}")

    dim objDataClass
    set objDataClass = nse.AddDataBlock (objDCInstance)

    'Add a new row
    dim objDataRow
    set objDataRow = objDataClass.AddRow
    'Set columns
    objDataRow.SetField 0, stringfont

    nse.SendQueued

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

     

     


     



  • 5.  RE: custom inventory registry help

    Posted Nov 17, 2011 01:04 PM

    Hi Toca,

    "stringfont" is just a variable that holds the value of Software\Microsoft\Office\9.0\Excel\Options \Font.  You could name it "George" and it wouldn't matter.  It's just a label.  The last parameter of a get (read) of a registry value using WMI is the value you are trying to pull:

    HKEY_CURRENT_USER,strKeyPath,strValueName1,stringfont

    From the screenshot of the error, it looks like you are getting a NULL value back from the script.  Check to make sure you don't have the "Key" or "Data required" dropdowns set to "Yes" in your custom data class.  SMP will add an _ID field to use as the key for you if you don't select one.  The nice thing about vbscript is you don't have to declare any variables - they are all variants when initialized anyhow (with a couple exceptions).

    For clarity, you can add a "Dim stringfont" on the line under your constant declaration if that helps you understand what that is for with a comment "the value of the font returned from the get" or something like that. 

    Take a look and let me know; we'll keep after this until we get it right for you.

     



  • 6.  RE: custom inventory registry help

    Posted Nov 18, 2011 07:46 AM

    Hi Douglas,

    I've gotten to the point where when i run the vbsscript; it does not give me an error anymore.

    but when i check the resource manager, i do not see the inventory in the table...

    I can't find the table if i look in sql managment studio.....

    not sure how to find the table or even know that the script worked.

    in ns6 i could see the table from resource manager of a machine under the default folder.....

    is there a way for me to check the inventory on the machine before it supposed to pass it to the server?

    thanks for all the help so far



  • 7.  RE: custom inventory registry help

    Posted Nov 18, 2011 09:17 AM

    If your custom data class is still named "Font", your custom inventory table name in the database will be named Inv_Font.

    In Resource manager, Click on View>Inventory.  Under Data Classes, open Inventory>Custom.  If it ran on your test device, your custom data class will be there along with the collected data.

    If you don't see the custom data class in the resource manager for your test device, take a look at the \Bad Q's on your SMP server to see if the Custom Inventory was rejected.  On your server, go to \\<servername>\c$\ProgramData\Symantec\SMP\EventQueue  Your custom inventory file will be <20k, so it will be processed in EvtQFast.  Check the EvtQFast\Bad Q's for your custom inventory.  It will be a small file and will look something like this (this is my IEVersion custom inventory):

    <?xml version="1.0"?>
    <message>
    <to>{1592B913-72F3-4C36-91D2-D4EDA21D2F96}</to>
    <priority>1</priority>
    <msgId>{A4F74F0C-23E2-4570-87C9-73A2E30BCB91}</msgId>
    <time>20111113024813.611000+300</time>
    <from>
     <resource typeGuid="{493435F7-3B17-4C4C-B07F-C23E7AB7781F}" guid="{69EFCDB4-E15D-40F9-80CE-D8EE4D3D23FC}" name="<removed for security>">
      <key name="name.domain" value="<removed for security"/>
      <key name="fqdn" value="<removed for security>"/>
      <key name="uniqueid" value="2p3LbM1PjfpP4Jlj4FYIjg=="/>
      <key name="uniqueid" value="lYkdIUB3a3d/RXHoZ4Bzpg=="/>
     </resource>
    </from>
    <body>
     <inventory>
      <dataClass guid="{1082f9a2-8f4b-463a-b33b-26c4c898fafc}">
       <data>
        <resource partialUpdate="false">
         <row c0="8.0000" c1="1" hash="xeXah57veK7xnoZVrf5KjQ=="/>
        </resource>
       </data>
      </dataClass>
     </inventory>
    </body>
    </message>
     

    I have two fields in my dataclass, IEVersion, and IsBranded (0 or 1) that tells me if it is our "official" install of IE8 or a rogue copy.  You will have a Row c0 and then the hash value.

    For where it's stored on the client prior to being sent, I don't recall, but I'll check through my various notes and see if I can find that.