Read-Host is unusable

Issue #7 new
Adam Driscoll created an issue

I have a basic menu that lets me choose options to do actions. Read-Host pops up another modal window that makes it essentially unusable. Here's the PowerShell menu code you can run and see:

function ShowMenu {
    Write-Host "====================="
    Write-Host "1. Option 1"
    Write-Host "2. Option 2"
    Write-Host "3. Option 3"
    Write-Host "Q. Exit"
    Write-Host "=====================`r`n"
}

function s1 {
    Write-Host "Option 1"
}

function s2 {
    Write-Host "Option 2"
}

function s3 {
    Write-Host "Option 3"
}

$choice = ""
while ($choice -ne "q"){
    ShowMenu #Display the menu options function

    $choice = read-host "`nSelection"
    switch ($choice)
    {
        q {break} #Return to main menu
        1 {s1}
        2 {s2}
    3 {s3}
        default {write-host "`nPlease choose a selection." -foregroundcolor red}
    }
}

image

Comments (1)

  1. Tim Fischer

    I also have an issue with Read-Host. The GUI Popup is totally unusable in my applications (it's how I pause when the app is configured to debug outside of VS). I can't stop debugging because of the modal window and it's an annoyance popup that does nothing for me. Is there a setting to disable the UI Popup? I just want the console to pause, not request input.

  2. Log in to comment