How to Inventory a Specific File Using Custom Inventory
search cancel

How to Inventory a Specific File Using Custom Inventory

book

Article ID: 178555

calendar_today

Updated On:

Products

Inventory Solution

Issue/Introduction

In some situations custom inventory is better than using file inventory for gathering information about a specific file 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 and 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 Broadcom/Symantec Support does not support custom scripting or reporting so modifications to the script and report must be made by the user.

178432 (Introduction to Custom Inventory in Notification Server 8.x [Altiris]) 

Environment

ITMS 8.x

Resolution

  1. Create a new custom data class that will store the file information for each computer.
    1. Go to Settings>All Settings then Settings>Discovery and Inventory>Inventory Solution>Manage Custom Data Classes.
    2. Click New data class.
    3. Name the data class something appropriate and click OK. Use this exact data class name later in the custom inventory script.
    4. Click Add attribute.
    5. Name the attribute "File", set Key to "No", and click OK.
    6. Add another attribute the same way named "Size".
    7. Click Save Changes.
  2. Create a Custom Inventory Script Task.
    1. Go to Manage>Jobs and Tasks.
    2. Browse the folder drop-down menu to where you would like to add a custom inventory script task.
    3. Right-click on the folder, then select New>Task.
    4. Select the Run Script task.
    5. Name the task appropriately.
    6. Select Script type: VBScript.
    7. Copy and paste the entire vbscript below into the large text box of the script task. Then edit the script to use the custom data class created in step 1-3, and the full path and name of the desired file.
      '*******************************************************
      'This Custom Inventory vbscript detects a specified file
      '*******************************************************
      
      set objFSO = CreateObject("Scripting.FileSystemObject")
      
      'Create the NSE
      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. The following data class with below guid is already configured on server.
      'Brackets are required around the dataclass guid. To get this GUID, click on the custom data class and then the hand (details).
      dim objDCInstance
      set objDCInstance = nse.AddDataClass ("Custom Data Class")  '***your custom data class name here 
      ' or "{GUID of CUSTOM DATA CLASS include brackets}"
      dim objDataClass
      set objDataClass = nse.AddDataBlock (objDCInstance)
      
      'Add a new row
      dim objDataRow
      set objDataRow = objDataClass.AddRow
      dim fileName
      fileName =  "c:\Program Files\Altiris\Altiris Agent\Agents\PatchMgmtAgent\AeXPatchUtil.exe" '***full path and name of the file to be detected
      if(objFSO.FileExists(fileName)) Then
       'If the file exist on the computer, get the details
       Set objFile = objFSO.GetFile(fileName)
       objDataRow.SetField 0,  objFile.Name
       objDataRow.SetField 1,  objFile.Size
      Else
       objDataRow.SetField 0,  "Not Found"
      End If
      
      ' Send the NSE data to the NS server
      nse.SendQueued
      ' msgBox nse.XML '***Uncomment this line for testing
  3. Run the Custom Inventory Script task
    1. Click on New Schedule, choose Now or specify a schedule time and repeat interval.
    2. Specify target computers to run the task on.
    3. 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.
    4. To target a list of computers click on Add>Computers or Devices then manually select the desired computers and click > and OK.
    5. 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.
  4. Create a Custom Report to view the data collected by the custom inventory
    1. Go to Reports>All Reports.
    2. Browse to a folder where you would like to add the custom report and right-click on the folder.
      Select New>Report>SQL Report.
    3. Give the report an appropriate name.
    4. 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 "_").
      select vComputer.Name, Inv_Custom_Data_Class.File, Inv_Custom_Data_Class.Size from Inv_Custom_Data_Class
      left join vComputer on vComputer.Guid = Inv_Custom_Data_Class._ResourceGuid
    5. Click Save Changes and then view the collected custom inventory data for each computer.

 

Additional Information

178794 Popular Custom Inventory Samples (8.x)

 

Attachments

Custom Users Folders Inventory.txt get_app
Custom Inventory for File Attributes.txt get_app
Custom File Inventory-Loop through folders.txt get_app