у меня есть простой код с меню, мне нужно добавить на 3 выполнение 1 и 2 действия сразу
можно ли как-то обьеденить 1, и 2 код в блок, добавить этому блоку переменную,
а в 3 действии просто выполнить эту переменную?
код:
7 {
$menu5 = $true
while ($menu5) {
Clear-Host
Write-Host
Write-Host " [1] Cleaning WinSXS (run after a windows update)" -ForegroundColor Green
Write-Host " [2] CompactOS (system file compression)" -ForegroundColor Green
Write-Host " [3] complete everything" -ForegroundColor Green
Write-Host
Write-Host " [0] break" -ForegroundColor Red
Write-Host
$subOption = Read-Host " your choice"
switch ($subOption) {
1 {
Write-Host
Write-Host " you have selected the option 1" -ForegroundColor Green
Write-Host
dism /online /cleanup-image /scanhealth
dism /online /cleanup-image /checkhealth
dism /online /cleanup-image /restorehealth
dism /online /cleanup-image /startcomponentcleanup
pause
Clear-Host
break
}
2 {
Write-Host
Write-Host " you have selected the option 2" -ForegroundColor Green
Write-Host
compact /compactos:query
compact /compactos:always
pause
Clear-Host
break
}
3 {
Write-Host
Write-Host " you have selected the option 3" -ForegroundColor Green
Write-Host
Write-Host "Выполнить 1 и 2 действие в этом блоке" -ForegroundColor Green
Clear-Host
break
}
0 {
$menu5 = $false
Clear-Host
}
default {
Write-Host
Write-Host " wrong choice" -ForegroundColor Red
Start-Sleep -Seconds 3
Clear-Host
break
}
}
}
}