Forum Discussion
RedModSK
Jun 19, 2023Copper Contributor
PromptForChoice menu not working in vertical mode.
Hello, i seek the wisdom of the community again. I have a script with few options in a menu and it works fine this way: $option1 = New-Object System.Management.Automation.Host.ChoiceDescription...
- Jun 19, 2023
There's two different overloads for PromptForChoice:
- The single return value definition:
PSHostUserInterface.PromptForChoice Method (System.Management.Automation.Host) | Microsoft Learn - The multiple choice return values definition:
IHostUISupportsMultipleChoiceSelection.PromptForChoice Method (System.Management.Automation.Host) | Microsoft Learn
You're using the multiple choice definition, where while that does indeed display vertically, it requires two consecutive <Enter> to confirm no further input, as a single enter simply accepts one value before letting you specify the next value on the next line.
See the example below:
I'm not aware of any way to make the single return value iteration of PromptForChoice to display vertically. That doesn't mean there isn't one, just that I'm unaware of one.
Cheers,
Lain
- The single return value definition:
NikolinoDE
Jun 19, 2023Platinum Contributor
$decision = $Host.UI.PromptForChoice($title, $question, $options, [int[]]@())
Maybe it helps 🙂
Maybe it helps 🙂
RedModSK
Jun 19, 2023Copper Contributor
Hello, NikolinoDE
Unfortunately it did not help.
$decision = $Host.UI.PromptForChoice($title, $question, $options, [int[]]@())
[S] Status
[D] Disable
[T] Start
[E] Enable
[C] Clean
[X] Exit
[?] Help
Choice[0]: D
Choice[1]:since "@" is used as array operator - how would it influence the action?