function Show-Tree {
    param(
        [string]$Dir,
        [int]$Level = 0
    )

    # 获取子目录和文件,忽略错误
    $items = Get-ChildItem -LiteralPath $Dir -ErrorAction SilentlyContinue | Sort-Object PSIsContainer, Name

    foreach ($item in $items) {
        $indent = " " * ($Level * 2)  # 每一级缩进2个空格

        if ($item.PSIsContainer) {
            Write-Output "$indent📁 $($item.Name)"
            # 递归子目录,忽略潜在错误
            Show-Tree -Dir $item.FullName -Level ($Level + 1)
        } else {
            Write-Output "$indent📃 $($item.Name)"
        }
    }
}

For those who alway want a file tree