Software Management Group

 View Only

How to Inventory a Specific File Type Using Altiris Custom Inventory - VB Script 

Feb 02, 2017 05:51 PM

This article presents a sample custom inventory script and custom report that displays the collected custom inventory data. This example looks for Access Database files with an extension of MDB. You can change the file type by changing MDB to the desired extension in the VB Script below where it says Extension='MDB'. 

 

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 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.
  • Check the "Allow multiple rows from a single computer resource." option 
  • Click Save Changes.
  • Highlight the new data class name and click the hand icon above to get to properties. Copy the GUID for later use in the custom script task.

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. Put the GUID copied above into the script (look for “This is the GUID for the custom data class”
  • Save Changes

VB Script Example

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

' Custom inventory VBS script to scan for a specific file type by extension

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

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

 

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

'This is the GUID for the custom data class

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

set objDataClass = nse.AddDataBlock (objDCInstance)

Set objCIMObj = objWMIService.ExecQuery("SELECT * FROM CIM_DataFile where Extension='MDB'")

 

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

nse.Send

 

Test and 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. (This uses the endpoint's local Windows System account, and this example assumes that account has rights to run a VB Script and to call WMI. You may need to provide alternate credentials)
  • 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_Name>
  • Click Save Changes and then view the collected custom inventory data for each computer targeted for the inventory.

 

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.

Statistics
0 Favorited
1 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Comments

Mar 20, 2019 10:27 AM

So I used your script to pull mdb since that is exactly what we are looking for, and when I run it manually from my machine it pulls all the mdb files into the db, but when I add it to altiris and run it as a task I only get 1 result.  Running it as system is appears to run too quick so figured maybe that was it, so told it to run as the end user which then does take some time, but still get the one result.

 

Any thoughts as to why its not running properly via altriris but seems to work fine when run manually?

Related Entries and Links

No Related Resource entered.