A PowerShell script that scans directories and displays a hierarchical tree view of folder and file sizes, similar to TreeSize Free.
$env:SystemDrive) when no path is provided-NoGui).\Get-TreeSize.ps1 [[-Path] <string>] [-Depth <int>] [-MinSize <long>] [-Gui] [-NoGui]
| Parameter | Description | Default |
|---|---|---|
| MDINLINECODE8148803fd8b6ff30d7306efd7958573eENDMDINLINECODE | Root directory to scan | System drive (MDINLINECODE20f7ab922410b1b08cb0469b60a286feENDMDINLINECODE) |
| MDINLINECODE334ee60d511ecfffebe7473c8f3fb123ENDMDINLINECODE | Maximum directory depth to display (MDINLINECODE1ee96f78ee0e9c54a17d1ba8fb833117ENDMDINLINECODE = unlimited) | MDINLINECODEcb8cedca37b9e310ed417b7650d61b66ENDMDINLINECODE |
| MDINLINECODE99e995f81a6ca19ffb30982f4b7afa8cENDMDINLINECODE | Minimum size in bytes to display an entry (supports MDINLINECODEfa2c26dcb8d4a3a89abdf7ff390dc3efENDMDINLINECODE, MDINLINECODEf58655cd9d4a89b22c23879d8c106178ENDMDINLINECODE) | MDINLINECODE3979e18ed9edfac11e870ed3f9f7a18cENDMDINLINECODE |
| MDINLINECODEa5b3277203879441f2f580b99e52538bENDMDINLINECODE | Force the Windows Forms GUI window (useful for clarity; GUI is already the default on Windows) | *(see below)* |
| MDINLINECODE8b228a8bd10acfa9cb261af6f52090bcENDMDINLINECODE | Print results to the console instead of opening the GUI window | *(GUI is default on Windows)* |
Platform behaviour: on Windows the GUI opens automatically unless-NoGuiis passed. On Linux/macOS the console output is always used; passing-Guion a non-Windows system raises an error.
# Scan the system drive – opens the interactive tree window on Windows (default)
.\Get-TreeSize.ps1
# Scan a specific directory
.\Get-TreeSize.ps1 -Path "C:\Users"
# Scan with a depth limit of 3 levels
.\Get-TreeSize.ps1 -Path "D:\" -Depth 3
# Only show entries larger than 100 MB
.\Get-TreeSize.ps1 -Path "C:\Windows" -MinSize 100MB
# Print to the console instead of opening the GUI window
.\Get-TreeSize.ps1 -Path "C:\Users\Demo" -NoGui
-NoGui)Scanning 'C:\Users\Demo' ...
300.56 MB C:\Users\Demo
175.00 MB Videos
75.00 MB Downloads
24.00 MB Music
21.56 MB Documents
15.06 MB Personal
6.50 MB Work
6.00 MB Reports
5.00 MB Pictures
5.00 MB Vacation
Total: 300.56 MB