PowerTree Provides Visualization of Directory Structures in PowerShell

Visualize directory structures in PowerShell with advanced filtering, sorting, and display options

PowerShell

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:

  • Get detailed file information (size, dates, attributes)
  • Use multiple sorting options (by name, size, date etc.)
  • Use filtering capabilities (by extension, size, directory)
  • Customize the configuration via JSON

Install PowerTree

PowerTree only works in PowerShell 7 and later versions. To install it, use the following command:

Install-Module PowerTree -Scope CurrentUser

Documenting file systems with PowerShell and PowerTree

The Start-PowerTree cmdlet has two aliases:

  1. ptree
  2. PowerTree

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:

Documenting file and folders in PowerShell using PowerTree
Documenting file and folders in PowerShell using PowerTree (Image Credit: Russell Smith/Petri.com)

PowerTree also supports writing the output to a file using the -OutFile option.

Output a file structure to a text file
Output a file structure to a text file (Image Credit: Russell Smith/Petri.com)

You can find a full list of the options for PowerTree on GitHub.