List All Folders and Subfolders

Ever wanted to create a list of all folders and subfolders? It just takes one line:

dir -recurse | Where-Object { $_.PSIsContainer } | ForEach-Object { $_.FullName }

First, you list everything from your current location. To filter out only folders, we then filter for PSIsContainer, a property that is always true for folders. Finally, we output each folders' full path.


Posted Jul 22 2009, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.