Submitted By: Chris Harrod

Searches a set of computers for files with a specified extension.

Visual Basic
Edit|Remove
' find files
' POC chris.harrod@gmail.com

on error resume next

Const CONVERSION_FACTOR = 1048576

Set objNet = WScript.CreateObject( "WScript.Network" )

strFilename = "c:\scripts\list.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objTextStream = objFSO.OpenTextFile(strFilename, 1)

Do Until objTextStream.AtEndOfStream

 	strComputer = objTextStream.ReadLine
 	' Wscript.Echo strComputer
	Set objWMIService = GetObject _
    ("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
	
	Set colFiles = objWMIService.ExecQuery _
	    ("Select * from CIM_DataFile where extension = 'oab'")
	
	For Each objFile in colFiles
	    searchFileSize = objFile.FileSize / CONVERSION_FACTOR
	    Wscript.Echo strComputer & " " & objFile.Name & " Size: " & Int(searchFileSize) & "MB"


	Next
Loop