0

Stupid question but not sure if this is possible.

I have a file server hosting 8 separate shares. I was looking for a script to pull a list of the folder names (No subfolders) for all of the shares.

I can use Get-ChildItem -path "\server1\share1*" | Where {$_.PsIsContainer} to list the folders of a specific share but I'm trying to find a way to just use the server path to list all shares and folders at once.

Is the only option to run the script individually for each share?

1
Get-WmiObject -Query "SELECT Name, Path FROM Win32_Share" | Format-Table Name, Path
0

It sounds like you want the -recurse parameter for Get-Childitem, this lists the contents of each folder beneath (and their contents too), though if there are many folders this might become unwieldy.

Another option is to use wildcards (*).

Get-Childitem -path "\server1\*\*"

This will search any folders in "\server1" and then any folders in those folders, if you want it to go deeper (dir-ception!) you can just add more "*".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.