PowerTip: Quickly Show Folders and Subfolders in PowerShell 3.0

Summary: Use Windows PowerShell 3.0 to quickly show folders and subfolders.

Hey, Scripting Guy! Question How can I use Windows PowerShell 3.0 to quickly show folders and subfolders?

Hey, Scripting Guy! Answer Use the Get-ChildItem cmdlet with the –Directory and the –Recurse switch. Select only parent and name. This command is shown here. Sort on the parent property. 

gci -Recurse -Directory | select parent, name | sort parent

Note  gci is an alias for Get-ChildItemselect is an alias for Select-Object, and sort is an alias for Sort-Object.