title: How to use invoke-command in powershell, to run a script on remote machine
body: <p>Is it possible to use <code>Invoke-Command</code> in PowerShell to run a script on a remote machine?</p>
  
  <p>I have tried :</p>
  
  <pre><code>Invoke-Command -ComputerName $MyPC -Credential $mycreds -ScriptBlock {
      &amp; "C:\Users\MyPC\Desktop\scripts\Script1.ps1"
  }
  </code></pre>
  
  <p>which returns</p>
  
  <pre><code>script1.ps1 is not recognized as the name of a cmdlet
  </code></pre>
  
  <p>The scenario here is, I have some scripts on a remote folder, and I need to use <code>Invoke-Command</code> or some other ways to run the script on a remote machine.</p>
  
  <p>Also, how  to write if I want to pass some parameters for <code>script1.ps1</code>? Thanks in advance!</p>