|
Optimizing PS Script to List directories Hey,
If I run the command below it will list all directories that have the
word "Data" in the path, if I run it locally it's real quick and can
find all the paths within seconds, but I need to run it on all our
remote file servers and it is dog slow and was wondering if anyone
knew anyway to optimise it?
get-childitem \\server\e$ "Data" -recurse | Where-Object {$_.mode -
match "d" } | Select-Object fullname
I am assuming it is slow because the first path of the command
searches the entire file system to find all folders AND files that
match "Data", then it is piped into the second part where it is then
restricted down to folders and then on the second part when it is then
restricted down to only output the path. It tries to bring across way
too much information across the WAN to have it filtered down on my
machine.
I need to extract about 10 - 15 paths on 102 remote files servers, if
it takes hours to do each server it's not worth doing a script and
I'll just have to find them manually. The path I am looking for is
never going be deep down in the file structure, it should be three
levels down from root, and I don't want files, just the folder path,
like ...
\\server\x$\BusinessUnitX\Folder1\Data
\\server\x$\BusinessUnitY\Folder1\Data
Anyone have any ideas?
Thanks |