Добрый день. Начал изучение PowerShell.
Как можно проще описать "выбиралку"?
Пока придумал только такой вариант:
function swit{
$choice = Read-Host Введите номер
switch($choice){
1{
Write-Host 1.Нажали 1 -ForegroundColor Green
Write-Host 2.Нажали 2 -ForegroundColor Red
Write-Host 3.Нажали 3 -ForegroundColor Red
Write-Host 4.Нажали 4 -ForegroundColor Red
Write-Host 5.Нажали 5 -ForegroundColor Red
Write-Host 6.Нажали 6 -ForegroundColor Red
Write-Host 7.Нажали 7 -ForegroundColor Red
Write-Host 8.Нажали 8 -ForegroundColor Red
Write-Host 9.Выход -ForegroundColor Red
swit}
2{ Write-Host 1.Нажали 1 -ForegroundColor Red
Write-Host 2.Нажали 2 -ForegroundColor Green
Write-Host 3.Нажали 3 -ForegroundColor Red
Write-Host 4.Нажали 4 -ForegroundColor Red
Write-Host 5.Нажали 5 -ForegroundColor Red
Write-Host 6.Нажали 6 -ForegroundColor Red
Write-Host 7.Нажали 7 -ForegroundColor Red
Write-Host 8.Нажали 8 -ForegroundColor Red
Write-Host 9.Выход -ForegroundColor Red
swit}
3{ Write-Host 1.Нажали 1 -ForegroundColor Red
Write-Host 2.Нажали 2 -ForegroundColor Red
Write-Host 3.Нажали 3 -ForegroundColor Green
Write-Host 4.Нажали 4 -ForegroundColor Red
Write-Host 5.Нажали 5 -ForegroundColor Red
Write-Host 6.Нажали 6 -ForegroundColor Red
Write-Host 7.Нажали 7 -ForegroundColor Red
Write-Host 8.Нажали 8 -ForegroundColor Red
Write-Host 9.Выход -ForegroundColor Red
swit}
4{ Write-Host 1.Нажали 1 -ForegroundColor Red
Write-Host 2.Нажали 2 -ForegroundColor Red
Write-Host 3.Нажали 3 -ForegroundColor Red
Write-Host 4.Нажали 4 -ForegroundColor Green
Write-Host 5.Нажали 5 -ForegroundColor Red
Write-Host 6.Нажали 6 -ForegroundColor Red
Write-Host 7.Нажали 7 -ForegroundColor Red
Write-Host 8.Нажали 8 -ForegroundColor Red
Write-Host 9.Выход -ForegroundColor Red
swit}
5{ Write-Host 1.Нажали 1 -ForegroundColor Red
Write-Host 2.Нажали 2 -ForegroundColor Red
Write-Host 3.Нажали 3 -ForegroundColor Red
Write-Host 4.Нажали 4 -ForegroundColor Red
Write-Host 5.Нажали 5 -ForegroundColor Green
Write-Host 6.Нажали 6 -ForegroundColor Red
Write-Host 7.Нажали 7 -ForegroundColor Red
Write-Host 8.Нажали 8 -ForegroundColor Red
Write-Host 9.Выход -ForegroundColor Red
swit}
6{ Write-Host 1.Нажали 1 -ForegroundColor Red
Write-Host 2.Нажали 2 -ForegroundColor Red
Write-Host 3.Нажали 3 -ForegroundColor Red
Write-Host 4.Нажали 4 -ForegroundColor Red
Write-Host 5.Нажали 5 -ForegroundColor Red
Write-Host 6.Нажали 6 -ForegroundColor Green
Write-Host 7.Нажали 7 -ForegroundColor Red
Write-Host 8.Нажали 8 -ForegroundColor Red
Write-Host 9.Выход -ForegroundColor Red
swit}
7{ Write-Host 1.Нажали 1 -ForegroundColor Red
Write-Host 2.Нажали 2 -ForegroundColor Red
Write-Host 3.Нажали 3 -ForegroundColor Red
Write-Host 4.Нажали 4 -ForegroundColor Red
Write-Host 5.Нажали 5 -ForegroundColor Red
Write-Host 6.Нажали 6 -ForegroundColor Red
Write-Host 7.Нажали 7 -ForegroundColor Green
Write-Host 8.Нажали 8 -ForegroundColor Red
Write-Host 9.Выход -ForegroundColor Red
swit}
8{ Write-Host 1.Нажали 1 -ForegroundColor Red
Write-Host 2.Нажали 2 -ForegroundColor Red
Write-Host 3.Нажали 3 -ForegroundColor Red
Write-Host 4.Нажали 4 -ForegroundColor Red
Write-Host 5.Нажали 5 -ForegroundColor Red
Write-Host 6.Нажали 6 -ForegroundColor Red
Write-Host 7.Нажали 7 -ForegroundColor Red
Write-Host 8.Нажали 8 -ForegroundColor Green
Write-Host 9.Выход -ForegroundColor Red
swit}
9{ Write-Host ″Выход″; break}
default {Write-Host ″Неверное значение, попробуйте еще раз.″ -ForegroundColor Magenta
swit}
}
}
swit