View Single Post
Old 06-24-2007   #5 (permalink)
Jacques Barathon [MS]


 
 

Re: Optimizing PS Script to List directories

"spdr" <pear@iinet.net.au> wrote in message
news:1182392599.525362.127170@e9g2000prf.googlegroups.com...
....
> 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


Roman's answer with GetDirectories() might just be what you need. I also
wanted to highlight an interesting feature of PowerShell which is not very
well known:

PS> dir \\server\x$\BusinessUnit*\Folder*\Data\*

.... will list all items in both BusinessUnitX\Folder1\Data and
BusinessUnitY\Folder1\Data folders, plus BusinessUnitX\Folder2\Data if it
exists, etc.

Might help you target your search more easily.

Jacques


My System SpecsSystem Spec