Как показать дерево каталогов в Powershell с заданной глубиной?
Вы можете использовать командлет Show-Tree
из проекта расширения сообщества PowerShell.
Чтобы установить 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
Чтобы получить помощь по 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".
Пример вывода:
> Show-Tree f:\test –depth 2
F:\test
├──subdir
│ └──child
├──test
├──test with space
│ └──child
└──test.with.dot
└──child
>