How to Use Custom Inventory for Windows to Gather Registry Information from Multiple Keys
Filed under:
Inventory Solution
Inventory
Submitted by dougj on Thu, 2008-05-15 15:25.
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:
- 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.
- 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>
(50 votes)
- Login or register to post comments
- 602 reads
- Printer-friendly version
















Thanks for the pointer
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!
look for the custom inventory tool
Tthere is a tool on juice called custinv that can help out a lot.
Good luck
Jonathan Jesse
Director of Training
ITS Partners