Video Screencast Help

NS7 Custom Inventory Script - Read Registry Keys

Created: 08 Sep 2011 • Updated: 08 Sep 2011 | 2 comments
This issue has been solved. See solution.

Hi there.  I'm new to Altiris and this is my first post.

I'm trying to create a custom inventory that reads the values of specific registry keys that my company stamps each machine with.  I've found several NS6 scripts that do this and I tried utilizing them in NS7 using the instructions in this article but my new data class doesn't appear in the client inventory.  Unfortunately I haven't found much in the way of NS7 VB scripts that I can use.  I am not skilled at scripting and was not able to decipher the complex (to me) NS7 VB scripts to the point where I could make use of them.

So my solution could be in one of two ways:  Figure out why my NS6 script isn't working in NS7, or if someone could kindly provide a basic VB script that inventories all the values of a specific registry key into a dataclass, that would extremely helpful!

Thanks,

Comments 2 CommentsJump to latest comment

fabio.sanches's picture

Hi Jaez,

Could you please provide more details about which registry keys are you looking for inventory?

Regards,

jaezbrfs's picture

Naturally I figured it out shortly after I created this post :)  For those like me who aren't great with VB, I used a sample script from this page and tweaked it like so:
 

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

const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
Set oReg=GetObject( _
   "winmgmts:{impersonationLevel=impersonate}!\\" &_
    strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\XXXXXX\BuildInfo"
strValueName1 = "freshnessdate"
strValueName2 = "site"
strValueName3 = "Win_7"
strValueName4 = "Win_XP"
oReg.GetStringValue _
   HKEY_LOCAL_MACHINE,strKeyPath,strValueName1,freshnessdate
oReg.GetStringValue _
   HKEY_LOCAL_MACHINE,strKeyPath,strValueName2,site
oReg.GetStringValue _
   HKEY_LOCAL_MACHINE,strKeyPath,strValueName3,buildversion7
oReg.GetStringValue _
   HKEY_LOCAL_MACHINE,strKeyPath,strValueName4,buildversionxp

'WScript.Echo "Request ID: " & freshnessdate
'WScript.Echo "Computer Description: " & site

if isnull(freshnessdate) then
  freshnessdate = "missing"
end if

if isnull(site) then
  site = "missing"
end if

if isnull(buildversion7) then
  buildversion7 = "missing"
end if

if isnull(buildversionxp) then
  buildversionxp = "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 ("{PUT YOUR DATACLASS GUID HERE}")

dim objDataClass
set objDataClass = nse.AddDataBlock (objDCInstance)

'Add a new row
dim objDataRow
set objDataRow = objDataClass.AddRow
'Set columns
objDataRow.SetField 0, buildversion7
objDataRow.SetField 1, buildversionxp
objDataRow.SetField 2, site
objDataRow.SetField 3, freshnessdate

nse.SendQueued

SOLUTION