Como mostro uma árvore de diretórios no Powershell com uma profundidade específica?
Você pode usar o cmdlet Show-Tree
do projeto de extensão de comunidade do PowerShell .
Para instalar o show-tree
:
> Install-Script -Name Show-Tree
Untrusted repository
You are installing the scripts from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install
the scripts from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): a
Para obter ajuda sobre show-tree
:
> get-help show-tree
NAME
Show-Tree
SYNOPSIS
Shows the specified path as a tree.
SYNTAX
Show-Tree [[-Path] <String[]>] [[-Depth] <Int32>] [-Force] [-IndentSize <Int32>] [-ShowLeaf] [-ShowProperty] [-ExcludeProperty <String[]>] [-Width <Int32>] [-UseAsciiLineArt] [<CommonParameters>]
Show-Tree [[-LiteralPath] <String[]>] [[-Depth] <Int32>] [-Force] [-IndentSize <Int32>] [-ShowLeaf] [-ShowProperty] [-ExcludeProperty <String[]>] [-Width <Int32>] [-UseAsciiLineArt]
[<CommonParameters>]
DESCRIPTION
Shows the specified path as a tree. This works for any type of PowerShell provider and can be used to explore providers used for configuration like the WSMan provider.
RELATED LINKS
REMARKS
To see the examples, type: "get-help Show-Tree -examples".
For more information, type: "get-help Show-Tree -detailed".
For technical information, type: "get-help Show-Tree -full".
Exemplo de saída:
> Show-Tree f:\test –depth 2
F:\test
├──subdir
│ └──child
├──test
├──test with space
│ └──child
└──test.with.dot
└──child
>