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 |
|---|---|---|
| MDINLINECODE12d7de204a5551a63f6969dbd6955cd1ENDMDINLINECODE | Root directory to scan | System drive (MDINLINECODE12dbdaef26e6553feb4e14f65063cd4bENDMDINLINECODE) |
| MDINLINECODE1b1059e60ce995ae2a4ade8531a427d4ENDMDINLINECODE | Maximum directory depth to display (MDINLINECODE8ff77a63c4edde9e73527469fda9cf22ENDMDINLINECODE = unlimited) | MDINLINECODEf9acc8ec43c1b2ec199146f242ef2c59ENDMDINLINECODE |
| MDINLINECODEc11b761791e253a90cd5d6743de0a705ENDMDINLINECODE | Minimum size in bytes to display an entry (supports MDINLINECODE6eabf9dd81909cdd68fb76bef916a166ENDMDINLINECODE, MDINLINECODEe87d9cad9c1c86f43c9be06fe7a445eeENDMDINLINECODE) | MDINLINECODEf68d5054660dc162de73b935333490c5ENDMDINLINECODE |
| MDINLINECODEaa17bc24902db3569a12eb9d9e2fb8aaENDMDINLINECODE | Force the Windows Forms GUI window (useful for clarity; GUI is already the default on Windows) | *(see below)* |
| MDINLINECODE4b6772602098b2a8a5031c07b0ade7f6ENDMDINLINECODE | 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