我有一个 powershell 脚本(setup.ps1
),我们将其用作开发环境设置脚本的入口点。它需要一个参数:
param(
[Parameter(Position=0,HelpMessage="The targets to run.")]
[Alias("t")]
[string[]]
$Targets = "Help"
)
当我跑步时
PS > get-help .\setup.ps1 -detailed
在参数部分,我的帮助消息没有出现:
PARAMETERS
-Targets <String[]>
我需要做什么才能显示参数帮助消息?
您将某种风格的注释放在文件顶部,PowerShell 帮助系统可以对其进行解码。这是一个例子:
<#
.SYNOPSIS
.
.DESCRIPTION
.
.PARAMETER Path
The path to the .
.PARAMETER LiteralPath
Specifies a path to one or more locations. Unlike Path, the value of
LiteralPath is used exactly as it is typed. No characters are interpreted
as wildcards. If the path includes escape characters, enclose it in single
quotation marks. Single quotation marks tell Windows PowerShell not to
interpret any characters as escape sequences.
.EXAMPLE
C:\PS>
<Description of example>
.NOTES
Author: Keith Hill
Date: June 28, 2010
#>
function AdvFuncToProcessPaths
{
[CmdletBinding(DefaultParameterSetName="Path")]
param(
[Parameter(Mandatory=$true, Position=0, ParameterSetName="Path",
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage="Path to ...")]
[ValidateNotNullOrEmpty()]
[string[]]
$Path,
[Alias("PSPath")]
[Parameter(Mandatory=$true, Position=0, ParameterSetName="LiteralPath",
ValueFromPipelineByPropertyName=$true,
HelpMessage="Path to ...")]
[ValidateNotNullOrEmpty()]
[string[]]
$LiteralPath
)
...
有关更多信息,请参阅帮助主题 -man about_comment_based_help
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)