Friday, July 8, 2011

Powershell - List All Folders and Subfolders

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.

From: http://powershell.com/cs/blogs/tips/archive/2009/07/22/list-all-folders-and-subfolders.aspx

No comments: