Is there a choice command equivalent for Powershell that can allow over the 254 character limit? As the choice command functions, it only allows specified characters. Such as in the example below, only the Y or N characters can be typed.
choice /C YN /M "Y or N?"
if ($LASTEXITCODE -eq 2) {
Write-Output "You said N"
}
elseif ($LASTEXITCODE -eq 1) {
Write-Output "You said Y"
}
To spell it out: the
/mparameter ofchoice.exe, which specifies the prompt message, is limited to 254 characters, andchoice.exefails with longer arguments.To overcome this limit, you don't need an alternative to
choice.exe, however:Write-Host-NoNewLineto print your 254+-character message, followed by a space.choice.exewithout/m:For instance: