January 5th, 2013

PowerTip: Quickly Show Folders and Subfolders in PowerShell 3.0

Doctor Scripto
Scripter

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.

 

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.