如何在“Get-Help”中显示C#Cmdlet参数HelpMessage
我已经启动了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] [-WhatIf] [-Confirm] [] PARAMETERS -Confirm -Path -WhatIf This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. For more information, see about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216). ALIASES None REMARKS None
在PowerShell脚本中编写cmdlet时,我可以使用以下语法为参数添加帮助消息:
但是C#cmdlet中的等价物是什么?
你这样做是绝对正确的!
您只需要检查-Full
视图或使用-Parameter
获取特定参数的-Parameter
:
上述就是C#学习教程:如何在“Get-Help”中显示C#Cmdlet参数HelpMessage分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
PS C:> Get-Help Get-Workspace -Parameter Path -Path 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
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/942491.html