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

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

book

Article ID: 178720

calendar_today

Updated On:

Products

IT Management Suite Inventory Solution

Issue/Introduction

Is there a way to inventory a specific file type on the Users directory, for every user on the system for reporting purposes?

Environment

ITMS 8.x

Inventory Solution 8.x

Resolution

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 is also available in the "Related Articles" section on the right side of this article:

178432 Introduction to Custom Inventory in Notification Server 8.x

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 in the following Microsoft article: 

CIM_DataFile class

Attachments

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