How can I input \"yes\" as an answer to an interactive question in a PowerShell session? I know, in Bash, Yes
is the tool to answer \"yes\" on the prompt. In my
I was trying to kill a pesky startup program and found that the Stop-Process and / or the program would not accept a piped input (no Echo Y | for me!) but I changed JPs answer a little bit: Stop-Process -name [program.name] -Force ; ran as administrator and it worked like a charm.
I was also having the same issue. The solutions tried by me included:
However, none of them seemed to do the trick.
What finally solved the problem was:
Powershell-Cmdlet -Confirm:$false
It suppresses all confirmation prompts for the duration of the command and the command would be processed without any confirmation.
Inspired by other answers, here is my example:
ECHO Y | powershell Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
You can test these old fashion ways :
Cmd /c "GpUpdate.exe /FORCE <C:\temp\response.txt"
ECHO 'Y' | GpUpdate.exe /FORCE
Get-Content "C:\temp\response.txt" | GpUpdate.exe /FORCE
Using ECHO worked for me. I am running RSKeyMgmt.exe in my Powershell script and it prompted Yes(Y)/ No(N). So when I do
ECHO Y | RSKeyMgmt.exe...
It did not prompt the question and the command was executed correctly.
So I think ECHO 'someoption'
should work for other cases too.