title: Process list of commands on remote machine with Invoke-Command
body: <p>I'm trying to write a powershell script that will take a list of commands and then run them on a remote machine, I have the following code:</p>
  
  <pre><code>foreach($command in $commands)
  {
    Invoke-Command -computer "BNEBAK" -scriptblock{"$command"}
  }
  </code></pre>
  
  <p>Which does not throw any error but also does not actually run the command (e.g stop-service servicename). $commands is read in from a text file passed as an argument when the script is called, I know the rest of this script works because I have been using it to do local commands with Invoke-Expression for some time.</p>
  
  <p>Any help would be fantastic. </p>