title: Create a process using Plink in PowerShell and sending commands to it
body: <p>I need to be able to create a process on a remote device and send come commands to it using a PowerShell script. I need to do it this way because I get prompts when I use a command. I have been trying to figure out how to do this by using Google searches and the following link: <a href="http://tartarus.org/~simon/putty-snapshots/htmldoc/Chapter7.html#plink" rel="nofollow">http://tartarus.org/~simon/putty-snapshots/htmldoc/Chapter7.html#plink</a>. From that link, I realized using a file with a list of commands in Plink won't work for the following reason (copied and pasted from that link): </p>
  
  <blockquote>
    <p>Any non-interactive command you could usefully run on the server
    command line, you can run in a batch file using Plink in this way.</p>
  </blockquote>
  
  <p>It says "non-interactive command", which is what I'm using. I have also tried using a file with a list of commands anyway, but it didn't solve my problem because I basically need to give a command, wait, and then give another one when it prompts me. This is what I found in the <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/faq.html#faq-ipc" rel="nofollow">PuTTY FAQ</a> and basically what I would like to try:</p>
  
  <blockquote>
    <p>Probably your best bet is to use Plink, the command-line connection
    tool. If you can start Plink as a second Windows process, and arrange
    for your primary process to be able to send data to the Plink process,
    and receive data from it, through pipes, then you should be able to
    make SSH connections from your program. This is what CVS for Windows does, for example.</p>
  </blockquote>
  
  <p><strong>EDIT:</strong> Based on the answer from user2460798, I have tried out the solution below. I'm hoping to use PuTTY and be able to send commands to it that way. My problem now is that I don't know how to send commands to the PuTTY session that gets opened. So basically this code opens up a PuTTY session and tries to write the "ls" command to it, but nothing happens. I have no idea where the "ls" text is going.</p>
  
  <pre><code>$procInfo = New-Object Diagnostics.ProcessStartInfo
  $procInfo.RedirectStandardOutput=$true
  $procInfo.RedirectStandardInput=$true
  $procInfo.RedirectStandardError=$true
  $procInfo.FileName="putty.exe"
  $procInfo.Arguments="-ssh -pw &lt;password&gt; &lt;username&gt;@&lt;device&gt;"
  $procInfo.UseShellExecute=$false
  $p=[diagnostics.process]::start($procInfo)
  sleep -Milliseconds 3000
  $p.StandardInput.WriteLine("ls")
  </code></pre>