Hi,
I have been using the code below to prompt the user to select from a choice of options. I got this code from
http://www.microsoft.com/technet/sc...p0125.mspx. However, I'm having trouble removing the default option. Everything I've read online (although not in this article) says that to not set a default, you can specify the final argument to PromptForChoice as -1. When I do this I get the following exeption:
Exception calling "PromptForChoice" with "4" argument(s): ""defaultChoice" must be a valid index into "choice". Parameter name: defaultChoice Actual value was -1."
<BR>$Caption = "Confirm"<BR>$Message = "Are you sure?"<BR>$Yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","help"<BR>$No = New-Object System.Management.Automation.Host.ChoiceDescription "&No","help"<BR>$Choices = [System.Management.Automation.Host.ChoiceDescription[]]($Yes,$No)<BR>$Answer = $host.ui.PromptForChoice($Caption,$Message,$Choices,0)<BR>
I've tried various combinations without success. Any suggestions as to where I'm going wrong would be much appreciated!
Thanks,
Nigel