Last active
March 31, 2026 18:43
-
-
Save davidlares/44e8d0df9f5d4bd569f174069876362f to your computer and use it in GitHub Desktop.
Powershell's version of the tree command (Linux fashion) + Filter included
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Show-Tree { | |
| param( | |
| [string]$Path = ".", | |
| [int]$Indent = 0 | |
| ) | |
| Get-ChildItem -LiteralPath $Path | | |
| Where-Object { $_.Name -ne "vendor" } | | |
| Sort-Object -Property @{Expression = {$_.PSIsContainer}; Descending = $true}, Name | | |
| ForEach-Object { | |
| $prefix = (" " * $Indent) + "|-- " | |
| Write-Output ($prefix + $_.Name) | |
| if ($_.PSIsContainer) { | |
| Show-Tree -Path $_.FullName -Indent ($Indent + 4) | |
| } | |
| } | |
| } | |
| Show-Tree |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment