title: Use Powershell to run Psexec command
body: <p>First post so please don't hurt me. I've searched around but can't seem to find a way to do what I want. I've made a script that copies a folder I have to numerous computers at \$computer\c$. In these folders is a batch file that runs an .exe. What I want to do is have Powershell pull from the same computers.txt that I used to copy the folder and then use psexec to run the batch file. I could do this all manually but scripting it seems to be a problem, here's what I thought would work but apparently not.</p>
  
  <pre><code>    $computers = gc "C:\scripts\computers.txt"
  
  foreach ($computer in $computers) {
  if (test-Connection -Cn $computer -quiet) {
      cd C:\pstools
      psexec \\%computer cmd
      C:\Folder\install.bat"
  } else {
      "$computer is not online"
  }
  </code></pre>
  
  <p>}</p>