I'm using the [ValidateSet()]
parameter attribute to validate that the input received by a user is included in the set of approved input values. However, I was wondering if there was a way of adding helper text to appear in the console when hovering over a given value included in the set.
function Get-ObjectAction
{
[cmdletbinding()]
param(
[parameter(
ParameterSetName = 'Interactive'
)]
[switch]$Interactive,
[parameter(
ParameterSetName = 'NonInteractive',
HelpMessage = "Select the Object to Synchronize: '0 = Users, Contacts and Groups', '1 = Users only', '2 = Contacts Only', '3 = Groups only'"
)]
[ValidateNotNullorEmpty()]
[ValidateSet(0, 1, 2, 3)]
[int]$Option
)
}
When I run the function in the console, auto-complete displays the available options, though I was wondering if there'd be a way to associate some helper text that would appear next to the autocomplete values for better usability.
Also, when declaring a validate parameter attribute (eg ValidateSet
, ValidateNotNullorEmpty
, etc.) the HelpMessage
specified seems to be skipped, and an exception related to PowerShell's inability to validate the parameter input is thrown instead. If the first question doesn't have a feasible answer, is there a way to forego the exception related to the parameter validation and prompt the user with the help message instead?