https://github.com/AlexAuras/PromptForChoice
A PowerShell module that prompts the user to select from a list of choices. It is a simple wrapper around the .NET function $Host.UI.PromptForChoice to simplify it's usage.
https://github.com/AlexAuras/PromptForChoice
Last synced: 5 months ago
JSON representation
A PowerShell module that prompts the user to select from a list of choices. It is a simple wrapper around the .NET function $Host.UI.PromptForChoice to simplify it's usage.
- Host: GitHub
- URL: https://github.com/AlexAuras/PromptForChoice
- Owner: AlexAuras
- License: mit
- Created: 2019-12-15T15:34:21.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-02T17:20:29.000Z (about 5 years ago)
- Last Synced: 2024-08-13T07:06:39.571Z (8 months ago)
- Language: PowerShell
- Size: 3.91 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - AlexAuras/PromptForChoice - A PowerShell module that prompts the user to select from a list of choices. It is a simple wrapper around the .NET function $Host.UI.PromptForChoice to simplify it's usage. (PowerShell)
README
# Prompt for Choice
## Introduction
Prompts the user to select from a list of choices. It is a simple wrapper around the .NET function [$Host.UI.PromptForChoice](https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.host.pshostuserinterface.promptforchoice) to simplify it's usage.
There is a nice [Windows PowerShell Tip of the Week](https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-powershell-1.0/ff730939(v=technet.10)) article that explains the usage of the .NET function.If you want to make your life easier, use this module.
## Examples
The module makes the usage really handy.
````
Get-Choice -Message "Do you really want this?" -YesNoDo you really want this?
[Y] Yes [N] No [?] Help (default is "Yes"):
````The shortest way to get a choice from the user.
````
Choice "Do you really want this?"Do you really want this?
[Y] Yes [N] No [?] Help (default is "Yes"):
````While the interface is optimized for simplicity, you still have all the power to define custom choices and help messages.
````
Choice "Do you really want this?" -Choices "&Yes", "&No", @{ Choice="&Dice"; Help="Can't decide? Go for a 50/50 Chance" }Do you really want this?
[Y] Yes [N] No [D] Dice [?] Help (default is "Yes"): ?
Y -
N -
D - Can't decide? Go for a 50/50 Chance
[Y] Yes [N] No [] Dice [?] Help (default is "Yes"):
````