I would like to be able to exit the script after using option 1 and Q. R for repeat works and any other key would bring me back to the Menu before. Can i just use another while ($response -eq "Q") ? or is the do while loop just wrong for that? i already tried a if else version but im doing it kinda wrong. Any help please?
function Show-Menu
{
param (
[string]$Title = 'Who? '
)
cls
Write-Host "================ $Title ================"
Write-Host "1: 1"
Write-Host "2: 2"
Write-Host "3: 3"
Write-Host "4: 4"
Write-Host "5: 5"
Write-Host "6: 6"
Write-Host "7: 7"
Write-Host "8: 8"
Write-Host "Q: Q to Quit."
}
do
{
Show-Menu
$input = Read-Host "Please choose."
switch ($input)
{
'1' {
cls
'You chose option #1'
do {
$response = Read-Host "R to repeat, Q to Quit or anything else to go back" }
while ($response -eq "R")
} '2' {
cls
'You chose option #2'
} '3' {
cls
'You chose option #3'
} 'q' {
return
} '3' {
cls
'You chose option #1'
} '4' {
cls
'You chose option #2'
} '' {
cls
'You chose option #3'
} 'q' {
return
}
}
pause
}
until ($input -eq 'q')