问题
I have started a PowerShell cmdlet and want to supply the help message for a parameter. I've tried using ParameterAttribute.HelpMessage for this:
[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();
    }
}
But when I use the PowerShell Get-Help command, it does not show the HelpMessage for the parameter:
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
When writing a cmdlet in PowerShell script I can add a help message for parameters using this syntax:
<#
.Parameter Path
The local path to the root folder of the workspace.
#>
But what is the equivalent in a C# cmdlet?
回答1:
You're doing it absolutely right!
You just need to inspect the -Full view or get help for the specific parameter with -Parameter:
PS C:\> Get-Help Get-Workspace -Parameter Path
-Path <string>
    The path to the root directory of the workspace.
    Required?                    true
    Position?                    1
    Accept pipeline input?       false
    Parameter set name           (All)
    Aliases                      None
    Dynamic?                     false
来源:https://stackoverflow.com/questions/32721832/how-to-get-c-sharp-cmdlet-parameter-helpmessage-to-show-up-in-get-help