function yesorno { write-host "Make your choice: `e[4my`e[24mes or `e[4mn`e[24mo" do { $k=[console]::readkey($true).keychar if ($k -notmatch "[yn]") { write-host "Please press 'y' or 'n'!" } } until ($k -match "[yn]") switch ($k) { 'y' { write-host "You have chosen 'yes'." } 'n' { write-host "You have chosen 'no'." } } }