Adding Custom Inventory to Standalone Inventory package

book

Article ID: 179386

calendar_today

Updated On:

Products

Inventory Solution

Resolution

Adding Custom Inventory to Standalone Inventory package, is available on release 8.5RU3.

Currently only VBscripts are supported to be embedded to Inventory StandAlone package.

 

HOW TO COLLECT CUSTOM VBS SCRIPTS VIA STANDALONE PACKAGE

  1. Create custom dataclass to store required data.
    1. In the Symantec Management Console, on the Settings menu, click All Settings.
    2. In the left pane, under Settings, expand Discovery and Inventory > Inventory Solution, and then click Manage Custom Data classes.
    3. On the Manage Custom Data Classes page, click New data class.
    4. On the New Data Class page, type a name and a description for the data class, and then click OK.
      • The name of the new data class must be unique.


         
    5. To define data class scheme (add data class attributes aka columns), perform the following actions in order:
    6. Click Save changes.
    7. To view the data class name, GUID, and other details, do the following:
      • On the Manage Custom Data Classes page, in the data classes list, click the data class, and then click the Hand icon.


         
  2. Create XML file containing data class definition, VB Script and mapping script output with data class columns. Separate file should be created for each custom data class. Format of file is the following:

    <dataClass name="Custom Dataclass 1" GUID="{d23111f2-b72c-46bd-af16-8c83bb7bd7d1}">

     <approaches>

      <approach type="script">

       <commands>

        <command scriptType="vbscript" function="execute" timeout="2400000">

         <scriptText>

                   <![CDATA[

         Function execute()

         Set resultset = CreateObject("Scripting.Dictionary")

         x = 0

         do

         Set rowDictionary=CreateObject("Scripting.Dictionary")

         rowDictionary.Add "c0", "field" & x & "1"

         rowDictionary.Add "c1", x

         rowDictionary.Add "c2", "somefield" & x

         resultset.add resultset.Count, rowDictionary

         x = x+1

         Loop while x < 3

         execute = SymInv_GetDataclassResults(resultset)

         End function

    ]]>

          </scriptText>

         <properties>

                   <property mapsTo="0">value1</property>

                   <property mapsTo="1">record number</property>

    <property mapsTo="2">some text</property>

         </properties>

        </command>

       </commands>

      </approach>

     </approaches>

    </dataClass>
    • Highlighted part is subject to be changed. Remaining parts are mandatory and should not be modified.
    • Define data class name and GUID. Values should match values from the Step 1g.
    • Modify content Function execute() so that it returns string like ‘<row c0=”field01” c1=”field02”\> <row c0=”field11” c1=”field12”\> <row c0=”field21” c1=”field22”\>’. Recommended to use predefined function SymInv_GetDataclassResults() – it returns correct string generating it from dictionary of output values(see provided sample and Appendix A)
    • Define mapping. It is required to define <property mapsTo="0">value1</property> for each column that need to be reported.
      • Value of attribute mapsTo corresponds to column index (for “c0” it is “0”, for “c1” it is ”1”, etc).
      • Value of node property is not used, so you may just put here some description or just set “value1” ,”value2”, “value3”, etc..
  3. Put all created prepared XML files to any specific folder on Notification Server
  4. Create new registry string value “HKEY_LOCAL_MACHINE\SOFTWARE\Altiris\Inventory\StandaloneCustomScripts” and set it to full path name to directory created in previous step
  5. Create new Standalone Package from Stand-alone Inventory Packages page (Settings > Discovery and Inventory > Inventory Solution > Stand-alone Inventory Packages)
    • When registry key StandaloneCustomScripts is defined, scripts located under specified folder will be embedded to standalone package during package creation process, but it is required to select at least one pre-defined data class for collection - it is not allowed to create package without any data classes selected in UI
    • Note: Altiris Log contains messages for each custom script, if format is invalid error is logged – search informational message “Importing custom inventory scriptsto review logs
  6. Execute created package on endpoints

 

NB:

  • Only VBS scripts are supported
  • Each custom script should be saved as separate file
  • Script must have Function execute() returning string like ‘<row c0=”field01” c1=”field02”\> <row c0=”field11” c1=”field12”\> <row c0=”field21” c1=”field22”\>’
  • All values must be XML escaped
  • StandAlone Packages cannot include only custom scripts, at least one predefined data class should be selected
  • Scripts may use predefined functions and constants (already embedded and existing in standalone package engine). List of functions below

 

List of predefined functions and constants.

Function SymInv_ReplaceIllegalCharacters(value)

value = Replace(value, "&", "&amp;")

value = Replace(value, "<", "&lt;")

value = Replace(value, ">", "&gt;")

value = Replace(value, "'", "&apos;")

value = Replace(value, """", "&quot;")

SymInv_ReplaceIllegalCharacters = value

End function

 

Function SymInv_GetDataclassResults(resultSet)

dim outerKey, rowDictionary

For Each outerKey in resultSet.keys

Set rowDictionary = CreateObject("Scripting.Dictionary")

Set rowDictionary = resultSet(outerKey)

outResults= outResults & "<row "

For Each key in rowDictionary.Keys

If Not IsNull(rowDictionary(key)) Then

outResults = outResults & " " & key &"=""" & SymInv_ReplaceIllegalCharacters(rowDictionary(key)) & """"

                  End if    

            Next

            outResults = outResults & "/> "

Next

SymInv_GetDataclassResults=outResults

End Function

 

Function SymInv_RunWmiQuery(query)

On Error Resume Next

set SymInv_RunWmiQuery=Nothing

Set objNetwork = CreateObject("Wscript.Network")

strComputer = objNetwork.ComputerName

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

set SymInv_RunWmiQuery = objWMIService.ExecQuery(query,"WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)

End function

 

Const HKEY_LOCAL_MACHINE = &H80000002

 

Function SymInv_GetRegProvider()

strComputer = "."

Set SymInv_GetRegProvider=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

End Function

 

 

Additional Information

REFERENCE ID : : 4245397

Attachments

StandAloneCustomInventory_test.vbs get_app
ASM_Internet_Explorer_Inventory.xml get_app