Comme je l'ai dit, ce code fonctionne dans la version PowerShell 2, mais pas dans la version PowerShell 5.Comment configurer un délai d'attente pour la lecture Host dans PowerShell
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..."
}}
i besoin de quelque chose comme ceci: echo -n « Pour poursuivre l'installation et ignorer les avertissements de configuration type [oui], tapez une touche pour annuler (l'installation sera automatiquement abort après 20 ans timeout): " lu 20 resp -t –