title: Waiting for user input with a timeout
body: <p>I have searched but apparently my google foo is weak. What I need is a way to prompt for user input in the console and have the request time out after a period of time and continue executing the script if no input comes in. As near as I can tell, Read-Host does not provide this functionality. Neither does $host.UI.PromptForChoice() nor does $host.UI.RawUI.ReadKey(). Thanks in advance for any pointers.</p>
  
  <p>EDIT: Much thanks to Lars Truijens for finding the answer. I have taken the code that he pointed out and encapsulated it into a function. Note that the way that I have implemented it means there could be up to one second of delay between when the user hits a key and when script execution continues.</p>
  
  <pre><code>function Pause-Host
  {
      param(
              $Delay = 1
           )
      $counter = 0;
      While(!$host.UI.RawUI.KeyAvailable -and ($counter++ -lt $Delay))
      {
          [Threading.Thread]::Sleep(1000)
      }
  }
  </code></pre>