Friday, 3 September 2021

PowerShell Menu

function Show-Menu
{
    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 
    $selection = Read-Host "Please make a selection"
    switch ($selection)
    {
        '1' {
            'You chose option #1'
               Write-Host `n
        } 
        '2' {
            'You chose option #2'
               Write-Host `n
        } 
        '3' {
            'You chose option #3'
               Write-Host `n
        } 
        'q' {
            return
        }
        default{
        Write-Host "Invalid Selection"
        Write-Host `n
        }
    }
}
until($selection -eq 'q')

No comments:

Post a Comment