Client Management Suite

 View Only

How to Use Custom Inventory for Windows to Gather Registry Information from Multiple Keys 

May 15, 2008 05:25 PM

It is possible to write custom inventory to gather data from more than one registry key. An example follows and is also found in the custom inventory samples repository (seek KB# 4237).

Notes:

  1. Apparently, the logic starts at the bottom key and works its way back up. So, we need to store the type and identifier values until we get back to the dmaenabled property.
  2. We can only clear out the curtype and curidentifier variables once we get back to the dmaenabled property. Otherwise, they'll be blank when we need them to populate the z:row data.
<?xml version="1.0" encoding="windows-1252"?>
<InventoryClasses>
<InventoryClass name='AeX OS DMA Status' manufacturer='Altiris' description='Reg Entries for OS Updates' version='1.0' platform='Win32' mifClass='Altiris|OSUpdates|1.0'>
<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
<s:Schema id="RowsetSchema">
<s:ElementType name="row" content="eltOnly" rs:updatable="true">
<s:AttributeType name="c0" rs:name="RegKeyName" rs:number="1" rs:nullable="true" mifAttrId="1">
<s:datatype dt:type="string" dt:maxLength="255"/>
</s:AttributeType>
<s:AttributeType name="c1" rs:name="DMAEnabled" rs:number="2" rs:nullable="true" mifAttrId="2">
<s:datatype dt:type="string" dt:maxLength="10"/>
</s:AttributeType>
<s:AttributeType name="c2" rs:name="Type" rs:number="3" rs:nullable="true" mifAttrId="3">
<s:datatype dt:type="string" dt:maxLength="255"/>
</s:AttributeType>
<s:AttributeType name="c3" rs:name="Identifier" rs:number="4" rs:nullable="true" mifAttrId="4">
<s:datatype dt:type="string" dt:maxLength="255"/>
</s:AttributeType>
</s:ElementType>
</s:Schema>
<rs:data>

<%set RegPath="HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SCSI"%>
<%foreach regkey="key1" path="%RegPath%" recurse=1%>

<%set sCheckPath="key:key1.%keypath%"%>
<%set sCheckType="reg:%sCheckPath%\type"%>
<%if %sCheckType%!=""%>
<%set curType="reg:%sCheckPath%\Type"%>
<%set curIdentifier="reg:%sCheckPath%\Identifier"%>
<%endif%>

<%set sCheckdma="reg:%sCheckPath%\DMAEnabled"%>
<%if %sCheckdma%!=""%>
<%set curKeyName="key:key1.%keyname%" %>
<%if %curType%!=""%>
<z:row
c0="<%writexml "%curKeyName%" %>"
c1="<%writexml "%sCheckdma%" %>"
c2="<%writexml "%curType%" %>"
c3="<%writexml "%curIdentifier%" %>"
<%set curType=""%>
<%set curIdentifier=""%>
/>
<%endif%>
<%endif%>

<%next%>
</rs:data>
</xml>
</InventoryClass>
</InventoryClasses>

Statistics
0 Favorited
0 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Comments

May 20, 2008 01:43 PM

Tthere is a tool on juice called custinv that can help out a lot.
Good luck
Jonathan Jesse
Director of Training
ITS Partners

May 16, 2008 10:06 AM

I've always considered "Custom Inventory" a bit of a dark-art...thanks for the pointer to the samples! Very useful, and a very good tip to boot!

Related Entries and Links

No Related Resource entered.