Powershell menu selection (e.g. GRUB, curses, etc.)

I want to provide the user with a menu in Powershell where he can select objects using the arrow keys, as in GRUB, or just the basic idea of ​​curses for replacing the inputs (Y) es or (N) o of the command line, (Or ​​to select a folder or what something else)

Is there already a framework or something that can help me as a starting point?

I already checked Out-GridView, but that leaves Powershell in another window.

+4
source share
1 answer

You need to use the System.Management.Automation.Host.ChoiceDescription .NET Framework class, which is designed for console menus.

For a very good use case, see the Technet Blog article.

EDIT: I missed the fact that you need the arrow keys / enter a CLI menu with a managed key.

I found a blog post from Jakob Bindslet, which seems to be exactly what you wanted, although I confess that I can’t try it yet, but I can’t wait!

EDIT: Another great option from Michael Albert can be found on his blog ; I found this option excellent because it does not clear the console window when navigating the arrow.

+7
source

Source: https://habr.com/ru/post/1490758/


All Articles