title: PowerShell - Respond to a Command response
body: <p>I am trying to write a simple script that will execute a console command in Windows, which will always ask for a confirmation for overwriting the existing data.  I thought something like the below would work, but it appears I was mistaken (and no surprise, write-host doesn't interact with the command line, I believe it simply puts text on screen).  Can anyone provide some advice on how to handle this?  I need to be able to execute the script through task scheduler on a weekly basis with no interaction.</p>
  
  <p>Script:</p>
  
  <pre><code>Start-Process -NoNewWindow -FilePath pw -ArgumentList @"
      threshold checkpoint create "WeeklyBackup" "WeeklyBackup"
  "@
  sleep -Seconds 3
  $confirm = Select-String -pattern "About to over-write existing CheckPoint 'WeeklyBackup'." -Quiet
  
  if ($confirm)
  {
     Write-Host "Y`r" 
  }
  </code></pre>
  
  <p>What I expect to see in the console:</p>
  
  <pre><code>D:\BMC_Software\ProactiveNet&gt;pw threshold checkpoint create "WeeklyBackup" "Week
  lyBackup"
  About to over-write existing CheckPoint 'WeeklyBackup'. Do you want to proceed?
  (y/n)
  </code></pre>
  
  <p>Then a user would hit Y and carriage-return and the process would be done.  But I want this automated.</p>
  
  <p>Thanks in advance for any advice.</p>