here is a basic script to get a basic file query after creating the remote share and removing the share when complete

 Code:
break on


$PC = 'pcname'    ; no backslashes
$SearchStr = '.xls'



$objWMIService = GetObject("winmgmts:\\" +$pc+ "\root\cimv2")

;	****** create remote share ******
$objNewShare = $objWMIService.Get("Win32_Share")
$errReturn = $objNewShare.Create("C:\", "C","0","2", "Temporary access for remote Windows Search.")
if not @error

;	****** query Windows Search ******
	$cn = CreateObject("ADODB.Connection") $cmd = CreateObject("ADODB.Command") $rs = CreateObject("ADODB.RecordSet")
	$cn.connectionstring = "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';"
	$cn.open			If @error	? 'Unable to connect to Windows Search'	endif
		$cmd.activeconnection = $cn	$rs.cursortype = 3	$rs.locktype = 3	$rs.activecommand = $cmd
		$cmdtxt = "SELECT System.ItemFolderPathDisplay, System.ItemName FROM "+$pc+".SystemIndex WHERE scope='file://"+$pc+"/c' and Contains(System.FileName,'"+$SearchStr+"') order by System.ItemFolderPathDisplay"
		$cmd.commandtext = $cmdtxt
		$rs.open($cmd)		If @error	? 'bad parameter in search query'	endif
			$count = 0
			$rs.MoveFirst
			While Not $rs.eof
				$fullpath = '' + $rs.fields.item("System.ItemFolderPathDisplay").value +'\'+$rs.fields.item("System.ItemName").value
				? $count
				? $fullpath 
				?
				$count =$count +1
				$rs.moveNext
			Loop
		? "Number of hits: " + $count 
		$rs.close
	$cn.close

;	****** delete remote share ******
	$colShares = $objWMIService.ExecQuery("Select * from Win32_Share Where Name = 'C'")
	For Each $objShare in $colShares
    		$nul = $objShare.Delete
	Next
endif



Edited by Radimus (2010-02-25 05:54 PM)
_________________________
How to ask questions the smart way <-----------> Before you ask