无法看到具有所需深度的“树”结构

3gw*_*ain 1 powershell windows-10

我正在使用 Windows 10,在powershell我想查看tree所需深度级别的文件夹结构。为此,我使用以下命令:

 tree -F -L 1
Run Code Online (Sandbox Code Playgroud)

但我想出了以下几点:

PS E:\Tutorials> tree -F -L 1
Too many parameters - -L
Run Code Online (Sandbox Code Playgroud)

这里有什么问题?什么是看到了正确的道路tree结构windows

提前致谢。

Dav*_*ill 5

如何在 Powershell 中显示具有指定深度的目录树?

您可以使用PowerShell 社区扩展项目中Show-Treecmdlet 。

安装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     
Run Code Online (Sandbox Code Playgroud)

获得帮助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".
Run Code Online (Sandbox Code Playgroud)

示例输出:

> Show-Tree f:\test –depth 2
F:\test
???subdir
?  ???child
???test
???test with space
?  ???child
???test.with.dot
   ???child
>
Run Code Online (Sandbox Code Playgroud)

  • -MaxDepth 代替 -Depth `语法 C:\Program Files\WindowsPowerShell\Scripts\Show-Tree.ps1 [[-Path] &lt;Object&gt;] [-MaxDepth &lt;Int32&gt;] [-ShowDirectory] ​​[-NotLike &lt;String[] &gt;] [-如 &lt;String[]&gt;] [&lt;CommonParameters&gt;]` (3认同)