'How to pass an answer to Read-Host if the cmdlet does not accept piped input? [duplicate]

I have code that runs and it hits this:

$reply = Read-Host -Prompt "Continue ?[y/n]"
if ($reply -match "[yY]")

I am trying to automate it. I tried using Echo 'Y' but I get an error message that his command (the one where that chunk of code exists in) does not accept input this way.

Is there a way to pass yes to it? I cannot change the code inside the cmdlet.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source