Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $MenuItems = ('1 - First item',
- '2 - Second choice',
- '3 - Third selection',
- 'x - Exit')
- $ValidChoices = $MenuItems | ForEach-Object {$_[0]}
- $Choice = ''
- while ($Choice -notin $ValidChoices)
- {
- Clear-Host
- $MenuItems
- Write-Output ''
- $Choice = (Read-Host "Please enter a choice from the above items ").ToLower()
- }
- Write-Output ''
- switch ($Choice)
- {
- '1' {Write-Output "Do the first thing."; break}
- '2' {Write-Output "The 2nd thing must be done."; break}
- '3' {Write-Output "Three is the number of the thing to do."; break}
- 'x' {Write-Output "Exit now."; break}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement