description | ms.date | ms.topic | title |
---|---|---|---|
Avoid using null or empty HelpMessage parameter attribute. |
06/28/2023 |
reference |
AvoidNullOrEmptyHelpMessageAttribute |
Severity Level: Warning
The value of the HelpMessage
attribute should not be an empty string or a null value as this
causes PowerShell's interpreter to throw an error when executing the function or cmdlet.
Specify a value for the HelpMessage
attribute.
Function BadFuncEmptyHelpMessageEmpty
{
Param(
[Parameter(HelpMessage='')]
[String]
$Param
)
$Param
}
Function BadFuncEmptyHelpMessageNull
{
Param(
[Parameter(HelpMessage=$null)]
[String]
$Param
)
$Param
}
Function BadFuncEmptyHelpMessageNoAssignment
{
Param(
[Parameter(HelpMessage)]
[String]
$Param
)
$Param
}
Function GoodFuncHelpMessage
{
Param(
[Parameter(HelpMessage='This is helpful')]
[String]
$Param
)
$Param
}