如何让C#Cmdlet参数HelpMessage显示在`Get-Help`中

时间:2015-09-22 16:15:22

标签: c# powershell cmdlet

我已启动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中的等价物是什么?

0 个答案:

没有答案