I want do provide the user with a menu in Powershell where he can select entities with the arrow keys just like in GRUB or just the very basic idea of curses to replace the (Y)es or (N)o command line inputs. (Or for folder selection or whatever)
Is there already a framework or something that can help me as a starting point?
I already checked the Out-GridView, but this leaves Powershell to another window.
Open a PowerShell console session, type exit , and press the Enter key. The PowerShell console will immediately close. This keyword can also exit a script rather than the console session.
PowerShell While loop As long as the condition is true, PowerShell will execute the script block until the condition results in false. Write-Host End of While loop. $var = 1 while ($var -le 5) { Write-Host The value of Var is: $var $var++ } Write-Host End of While loop.
You need to use the System.Management.Automation.Host.ChoiceDescription
.NET Framework class, which is designed for console menus.
For a very good example of use, see this Technet Blog article.
EDIT: I missed the fact that you wanted an arrow keys/enter key driven CLI menu.
I found a blog post from Jakob Bindslet that seems to be just what you wanted, although I confess I can't try it just yet, but I can't wait to!
EDIT: Another excellent option from Micahel Albert can be found on his blog; I found this option to be superior in that it does not clear the console window on arrow navigation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With