title: How to execute a powershell script available in remote machine?
body: <p>I was trying to execute a script in remote computer. </p>
  
  <p>I did "<code>Enable-PSremoting</code>" in the remote machine.</p>
  
  <p>I placed a script <code>hello.ps1</code> in remote machine.</p>
  
  <p>[My client machine is Windows XP and remote computer is Windows 2003 ]</p>
  
  <p>Then from my client computer i was trying to execute the script.</p>
  
  <pre><code>invoke-command -computer $MachineName -filepath "C:\hello.ps1"
  </code></pre>
  
  <p>I got the following error.</p>
  
  <blockquote>
    <p>Invoke-Command : Cannot find path 'C:\hello.ps1' because it does not
    exist.</p>
  </blockquote>
  
  <p>I think it tries to find script from client machine. </p>
  
  <p>If i try to run </p>
  
  <p><code>invoke-command -computer $MachineName -command { C:\hello.ps1 }</code> , It executes the script available in remote machine in client side.</p>
  
  <p>But i would like to execute the remote script in remote machine itself.</p>
  
  <p>How to make it to run the script available in remote machine?</p>
  
  <p>Updated: </p>
  
  <p>Actually this command "<code>invoke-command -computer $MachineName -command { C:\hello.ps1 }</code>" works in remote side and returned the result to client side. I misunderstood by seeing the return values that it is executing at client side.</p>