PowerShell Get-Help filename.ps1仅显示文件名

时间:2017-06-20 06:27:50

标签: powershell

在PowerShell 5.0 Get-Help中不显示脚本的基于注释的帮助。而是仅打印文件名。

对于此代码,不显示注释块的值:

# dare.ps1
<# 
.SYNOPSIS
     The answer
.DESCRIPTION
     Answer to the Ultimate Question of Life, the Universe, and Everything.
#>
"The answer to the Ultimate Question of Life, the Universe and Everything is {0}" -f 42 

命令

PS C:\> Get-Help .\dare.ps1

输出

dare.ps1

1 个答案:

答案 0 :(得分:5)

基于注释的帮助的打开需要在第一行,或者第一个注释或代码与基于注释的帮助块之间需要更多空间。

选项1 - 添加行空间

具有额外空间的代码

# dare.ps1

<# 
.SYNOPSIS
     The answer
.DESCRIPTION
     Answer to the Ultimate Question of Life, the Universe, and Everything.
#>
"The answer to the Ultimate Question of Life, the Universe and Everything is {0}" -f 42 

选项2 - 首先放置基于评论的帮助块

基于评论的帮助阻止

<# 
.SYNOPSIS
     The answer
.DESCRIPTION
     Answer to the Ultimate Question of Life, the Universe, and Everything.
#>
"The answer to the Ultimate Question of Life, the Universe and Everything is {0}" -f 42 

结果

NAME
    C:\dare.ps1

SYNOPSIS
    The answer


SYNTAX
    C:\dare.ps1 [<CommonParameters>]


DESCRIPTION
    Answer to the Ultimate Question of Life, the Universe, and Everything.