This can be MUCH more efficient. The command sequence you have here gets
the specified properties of all files on the remote machine, transfers them
across the network and then filters them locally. You'll want to do as
much of the filtering on the remote machine.
The optimal solution would be to install WIndows PowerShell on that remote
machine and use some flavor of a 3rd party remote execution command.
Alternatively, Get-WMIOBject takes a -FILTER parameter which allows you to
specify the WHERE clause of a WQL query. Here is an example of using a
filter against processes:
gwo win32_process -filter 'Name like "s%" AND handlecount > 400' |ft
For what you want, I think the command is:
gwo CIM_LOGICALFILE -computerName $computer -property
-filter 'Drive = "f:" AND path = "\\PowerShellScripts\\" and Name LIKE
Give that a try and I think it will be faster for you.
Here are a couple of good pointers to describe WQL: http://msdn.microsoft.com/library/de...e_operator.asp http://msdn.microsoft.com/library/de..._operators.asp
PSMDTAG:TYPE:WMI CIM_LOGICALFILE WQL
PSMDTAG:FAQ: How do I use -FILTER on Get-WMIObject?
Jeffrey Snover [MSFT]
Windows PowerShell Architect
This posting is provided "AS IS" with no warranties, no confers rights.
Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scr.../hubs/msh.mspx