Skip to content

Instantly share code, notes, and snippets.

@itsthedoc
Created August 2, 2018 08:38
Show Gist options
  • Save itsthedoc/7897bc49c832df12ced9fb3f74286eb2 to your computer and use it in GitHub Desktop.
Save itsthedoc/7897bc49c832df12ced9fb3f74286eb2 to your computer and use it in GitHub Desktop.
New-UserMenu creates a user selection menu in PowreShell
function Show-Menu
{
param (
[string]$Title = 'My Menu'
)
cls
Write-Host "================ $Title ================"
Write-Host "1: Press '1' for this option."
Write-Host "2: Press '2' for this option."
Write-Host "3: Press '3' for this option."
Write-Host "Q: Press 'Q' to quit."
}
do
{
Show-Menu
$input = Read-Host "Please make a selection"
switch ($input)
{
'1' {
cls
'You chose option #1'
} '2' {
cls
'You chose option #2'
} '3' {
cls
'You chose option #3'
} 'q' {
return
}
}
pause
}
until ($input -eq 'q')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment