List All Folders and Subfolders

by Jul 22, 2009

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.