The HelpMessage property

HelpMessage is only applied to Mandatory parameters and is not particularly useful. If a parameter is mandatory and is not passed when a command is called, a prompt for the parameter value will appear. Typing !? in the prompt, instead of a value, will display the help message text:

PS> function Test-HelpMessage {
>> param (
>> [Parameter(Mandatory, HelpMessage = 'Help text for Parameter1')]
>> $Parameter1
>> )
>> }
PS> Test-HelpMessage

cmdlet Test-HelpMessage at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
Parameter1: !?
Help text for Parameter1
Parameter1:

Given that HelpMessage is only visible when explicitly requested in this manner, it is most often ignored entirely. It is better to spend time writing help content for a parameter than writing values for HelpMessage.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.186.173