<# .SYNOPSIS list-dir.ps1 [] .DESCRIPTION Lists the directory content formatted in columns .EXAMPLE PS> ./list-dir C:\ .NOTES Author: Markus Fleschutz ยท License: CC0 .LINK https://github.com/fleschutz/PowerShell #> param([string]$Pattern = "*") function ListDir { param([string]$Pattern) $Items = get-childItem -path "$Pattern" foreach ($Item in $Items) { $Name = $Item.Name if ($Name[0] -eq '.') { continue } # hidden file/dir if ($Item.Mode -like "d*") { $Icon = "๐Ÿ“‚" } elseif ($Name -like "*.iso") { $Icon = "๐Ÿ“€" } elseif ($Name -like "*.mp3") { $Icon = "๐ŸŽต" } elseif ($Name -like "*.epub") { $Icon = "๐Ÿ““" } else { $Icon = "๐Ÿ“„" } new-object PSObject -Property @{ Name = "$Icon$Name" } } } try { ListDir $Pattern | format-wide -autoSize exit 0 # success } catch { "โš ๏ธ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" exit 1 }