title: How to configure a timeout for Read-Host in PowerShell
body: <p>Like I said, this code works in PowerShell version 2, but not in PowerShell version 5.</p>
  
  <pre><code>function wait
        {
         $compte = 0
          Write-Host  "To continue installation and ignore configuration warnings      type [y], type any key to abort"
            While(-not $Host.UI.RawUI.KeyAvailable -and ($compte -le 20))
           {
            $compte++
            Start-Sleep -s 1
            }
             if ($compte -ge 20)
             {
          Write-Host "Installation aborted..."
             break
             }
          else
              {
          $key = $host.ui.rawui.readkey("NoEcho,IncludeKeyup")
              }
           if ($key.character -eq "y")
              {Write-Host "Ignoring configuration warnings..."}
           else 
              {Write-Host "Installation aborted..." 
              }}
  </code></pre>