Reputation: 31526
If I have a parameter like this
[Parameter(Mandatory=$true, ParameterSetName='InsertException')]
[Parameter(Mandatory=$true, ParameterSetName='UpdateException')]
[string]$Requestor = ([Environment]::UserDomainName + '\' + [Environment]::UserName),
When someone runs my script like
.\myscript
the script should prompt him for the value... but it should show a default as well. the user can backspace and remove the default and key in new value.
But what happens is that when powershell prompts the user the value in the console is blank even though I am assigning a default value in the script (as you can see).
So how can I have a default value in the prompt?
Upvotes: 0
Views: 1210
Reputation: 201602
No can do. The best I think you can get is to use a HelpMessage
like so:
[Parameter(Mandatory=$true,
ParameterSetName='InsertException',
HelpMessage='The default value is foo')]
Then when the user encounters the prompt, they type !?
to see the help message.
Upvotes: 1