I don’t remember ever being prompted for multiple selections before in PowerShell, but I’ve seen several examples of hosts implementing this interface. Unfortunately, those are the only references I’ve seen to the interface. I’ve never seen “here’s how to test that you’re implementing it correctly”.
I don’t remember ever being prompted for multiple selections before in PowerShell, but I’ve
Share
Please, disregard my first answer; it is not an answer at all, as I can see now. And thank you for a really interesting question.
I still do not know cmdlets that use that interface. But we can use it on our own from scripts. Let’s modify the mentioned Get-Choice.ps1 and call the new one Get-Choice2.ps1:
Now we test it:
It prints 10 choices, the first 3 are highlighted (in the console host), and prompts:
If we press
Enterimmediately the output is the default 3 indexes: 0, 1, 2. If we type, for example:5 + Enter + 3 + Enter + 1 + Enter + Enterthen the output is 4, 2, 0.It works. PowerShell ISE also supports this but the UI might be something better in GUI version, perhaps.