title: How to make a Powershell script answer a prompt for user input?
body: <p>I have a Powershell script that needs to execute a command-line executable that prompts for user input (for which there is no command-line parameter). Something like this:</p>
  
  <pre><code># promptsForInput.ps1
  $someInput = Read-Host "Gimme some input"
  # do something with $someInput
  </code></pre>
  
  <p>The actual executable is a compiled binary which I cannot modify, but this example script do for the purposes of this question. My Powershell script calls the executable:</p>
  
  <pre><code># myScript.ps1
  .\promptsForInput.ps1
  </code></pre>
  
  <p>At runtime, I get prompted to input something:</p>
  
  <pre><code>&gt; .\myScript.ps1
  Gimme some input:
  </code></pre>
  
  <p>I need to be able to fill in that input request without user intervention. When <code>promptsForInput.ps1</code> prompts for user input, I need <code>myScript.ps1</code> to enter the required value and proceed with script execution.</p>
  
  <p>Similar questions on SO either have answers specific to the particular exe, or are otherwise unhelpful:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/14049002/how-to-fill-the-prompt-in-powershell-script">How to fill the prompt in powershell script</a></li>
  <li><a href="https://stackoverflow.com/questions/33650913/powershell-uninstall-software-that-has-prompts-for-user-input">Powershell: Uninstall Software that has prompts for user input</a></li>
  <li><a href="https://stackoverflow.com/questions/10352323/how-to-answer-a-console-input-prompt-in-powershell-in-the-code">How to &quot;answer&quot; a console input prompt in PowerShell (in the code)</a></li>
  <li><a href="https://stackoverflow.com/questions/20883310/how-to-write-to-user-input-in-powershell">How to write to user input in powershell</a></li>
  </ul>