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 |
|---|---|---|
| MDINLINECODE0d122be180905e9b783f40dd04b11196ENDMDINLINECODE | Root directory to scan | System drive (MDINLINECODE49dd47ddfc46a196e5d000be8119e3c9ENDMDINLINECODE) |
| MDINLINECODE76f8a9c988e37c073b51372c7836e217ENDMDINLINECODE | Maximum directory depth to display (MDINLINECODE1356f6d9264198eddd5a2befd4524764ENDMDINLINECODE = unlimited) | MDINLINECODEbd68445391dcc02d7ca7ab25821c1c50ENDMDINLINECODE |
| MDINLINECODEd9987f6ace8c09b31324036c2f6d7ab8ENDMDINLINECODE | Minimum size in bytes to display an entry (supports MDINLINECODEc1650584d55d287882e7d7808265b60dENDMDINLINECODE, MDINLINECODEece2613710ce2c6bca4636a8738dd228ENDMDINLINECODE) | MDINLINECODEca9c36f619811bc0b840fea327b4cf98ENDMDINLINECODE |
| MDINLINECODEf09403fa468e69ea958af88cbbc69d6bENDMDINLINECODE | Force the Windows Forms GUI window (useful for clarity; GUI is already the default on Windows) | *(see below)* |
| MDINLINECODEc50f4027cd8702efde53a47bd842bb10ENDMDINLINECODE | 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