Visualize directory structures in PowerShell with advanced filtering, sorting, and display options
PowerTree is a free tool that is now available to download for PowerShell 7+ on GitHub. It’s similar to the Windows tree command but provides advanced filtering, sorting, and display options that make exploring and documenting file systems more efficient.
For example, unlike the tree command in Windows, with PowerTree you can:
PowerTree only works in PowerShell 7 and later versions. To install it, use the following command:
Install-Module PowerTree -Scope CurrentUser
The Start-PowerTree cmdlet has two aliases:
Edit-PowerTreeConfig can be used to change the configuration.
I used the following command to document my C: drive.
Start-PowerTree -DisplaySize -SortBySize -Descending
The output took a while because it’s recursive by default although you can use the -Depth option to limit the output to a specific number of directory levels:
PowerTree also supports writing the output to a file using the -OutFile option.
You can find a full list of the options for PowerTree on GitHub.