我已启动 PowerShell cmdlet,并希望提供参数的帮助消息。我尝试过使用ParameterAttribute.HelpMessage
为了这:
[Cmdlet(VerbsCommon.Get, "Workspace", SupportsShouldProcess = true)]
public class GetWorkspace : PSCmdlet
{
[Parameter(
Mandatory = true,
Position = 1,
HelpMessage = "The path to the root directory of the workspace.")]
public string Path { get; set; }
protected override void ProcessRecord()
{
base.ProcessRecord();
}
}
但是当我使用 PowerShell 时Get-Help
命令,它不显示参数的 HelpMessage:
get-help Get-Workspace -det
NAME
Get-Workspace
SYNTAX
Get-Workspace [-Path] <string> [-WhatIf] [-Confirm] [<CommonParameters>]
PARAMETERS
-Confirm
-Path <string>
-WhatIf
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
ALIASES
None
REMARKS
None
在 PowerShell 脚本中编写 cmdlet 时,我可以使用以下语法添加参数帮助消息:
<#
.Parameter Path
The local path to the root folder of the workspace.
#>
但是 C# cmdlet 中的等效项是什么?