Create a Custom Inventory to search a system drive for any file in any path

book

Article ID: 178720

calendar_today

Updated On:

Products

Management Platform (Formerly known as Notification Server) Inventory Solution

Issue/Introduction

 

Resolution

A customer was wanting to inventory a specific file type on the Users directory, for every user on the system for reporting purposes.  Testing the File Properties of an Inventory Policy or Task did not work properly (and so using an Inventory Policy is not recommended for this type of work), so we went looking for a Custom Inventory.  Please find attached to this article a VB script that searches the hard disk for the Folder Name, and then for the File Type in that folder.  This worked great for us as it pulled data for each user on the computer.  Note that the task runs as the System Account which has access to all users files.

Some examples that have been created using this VB Script (other examples can be found on the internet):

EXAMPLE 1: Scan C:\ for MP4 files in any "USER" path:
Set objCIMObj = objWMIService.ExecQuery("SELECT * FROM CIM_DataFile where Drive='C:' and Extension='mp4' and path like '%users%'"

EXAMPLE 2: Scan for IExplore.exe in "Program Files":
Set objCIMObj = objWMIService.ExecQuery("SELECT * FROM CIM_DataFile where Drive='C:' and FileName = 'iexplore' and Extension='exe' and path like '%Program Files%'")

The user will also need to change this section of the code, depending on which outcome they want.  

'nse.SendQueued    'Send the NSE data to the NS server
'MsgBox nse.Xml    'Uncomment for testing on local machine

The process for creating a Custom Inventory is linked for your convenience, KB HOWTO10487 and is also available in the "Related Articles" section on the right side of this article.

Follow these instructions to create the Data Class and also the Task.

If there are other File Properties that you would like to use in this search, other CIM_DataFile Data Class options can be found here

Attachments

Cust Inv - Any Path and File Type.vbs.txt get_app