How to Inventory a Specific File Type Using Altiris Custom Inventory
search cancel

How to Inventory a Specific File Type Using Altiris Custom Inventory

book

Article ID: 178942

calendar_today

Updated On:

Products

Inventory Solution

Issue/Introduction

 

Resolution

In some situations custom inventory is better than using file inventory for gathering information about a specific file type from many different computers. By default file Inventory only detects detailed information for EXE and DLL files and has many exclusion rules built in to limit which folders it scans. It is possible to add inclusion rules to file inventory (see http://www.symantec.com/docs/HOWTO84131) to be able to report any desired files, however custom inventory is a far more efficient and reliable method when there is only one desired file with the same name and location on all computers. This article presents a sample custom inventory script and custom report that displays the custom inventory data. See the attachments for examples of more advanced custom inventory scripts. Please note that Symantec Support does not support custom scripting or reporting so modifications to the script and report must be made by the user.

Create a new custom data class that will store the file information for each computer.

  • Go to Settings>All Settings then Settings>Discovery and Inventory>Inventory Solution>Manage Custom Data Classes.
  • Click New data class.
  • Name the data class something appropriate (note this name for later) and click OK.
  • Click Add attribute.
  • Name the attribute "Computer Name" and set Key to "No", and click OK.
  • Add another attribute the same way named "File Location" and set Key to "No", and click OK.
  • Click Save Changes.

Create a Custom Inventory Script Task.

  • Go to Manage > Jobs and Tasks.
  • Browse the folder drop-down menu to where you would like to add a custom inventory script task.
  • Right-click on the folder, then select New > Task.
  • Select the Run Script task.
  • Name the task appropriately.
  • Select Script type: VBScript.
  • Copy and paste the entire vbscript below into the large text box of the script task
  • Modify the line with comment "'***Modify this line with the name of the custom dataclass"
  • Also modify the line with comment "'***File extension here" with the desired file extension
  • Save Changes

 

 

'*********************************************************

' Custom inventory VBS script to scan for MDB files (Access DB files)

'*********************************************************

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")

Set wshShell = WScript.CreateObject( "WScript.Shell" )

ComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )

dim nse

set nse = WScript.CreateObject ("Altiris.AeXNSEvent")

' Please don't modify this GUID

nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"

nse.Priority = 1

 

 

'*********************************************************

set objDCInstance = nse.AddDataClass ("Custom Data Class Name") '***Modify this line with the name of the custom dataclass

'set objDCInstance = nse.AddDataClass ("{PUT CUSTOM DATA CLASS GUID HERE AND LEAVE BRACKETS}") '***Alternative method

 

 

set objDataClass = nse.AddDataBlock (objDCInstance)

 

Set objCIMObj = objWMIService.ExecQuery("SELECT * FROM CIM_DataFile where Extension='mdb'") '***File extension here

For each objInfo in objCIMObj

                dim file_location

                file_location = objInfo.Drive + objInfo.Path + objInfo.FileName + "." + objInfo.Extension

                set objDataRow = objDataClass.AddRow

                objDataRow.SetField 0, CStr(ComputerName)

                objDataRow.SetField 1, file_location

Next

'msgbox nse.xml '***Uncomment this line for troubleshooting

nse.Send

 

 

Run the Custom Inventory Script task

  • NOTE: We recommend testing the script task prior to production runs to ensure there are no errors or pop-up windows.
  • In the Advanced section of the task (click Advanced), enable the option to hide the command window.
  • Leave the default Run As - Local System Account is preferred.
  • Click OK.
  • Click on New Schedule, choose Now or specify a schedule time and repeat interval.
  • Specify target computers to run the task on.
  • To target a single computer click in the Quick add: box and search for the name of the computer, or use the Quick Run feature instead of New Schedule.
  • To target a list of computers click on Add > Computers or Devices then manually select the desired computers and click > and OK.
  • To target a computer filter (such as All Computers) click on Add > Target, click Add rule, choose exclude computers not in, and search the name of the filter in the final drop-down box; then click OK.

Create a Custom Report to view the data collected by the custom inventory

  • Go to Reports > All Reports.
  • Browse to a folder where you would like to add the custom report and right-click on the folder.
  • Select New>Report > SQL Report.
  • Give the report an appropriate name.
  • Replace the text under Parameterized Query with the following query and then adapt it to use the custom data class table created in step 1-3 (the table will start with Inv_ followed by the custom data class name, with all spaces replaced with "_") You can also find the table name in the custom data class properties where the GUID was copied from.
    • select * from Inv_Custom_Data_Class
  • Click Save Changes and then view the collected custom inventory data for each computer.

Additional Information

KB 178304 “How to View Custom Inventory Data with a Custom Report”