title: PowerShell Running Remote Comman on a different path
body: <p>I can run remote powershell commands from my local machine to a server in a different domain by doing something like this:</p>
  
  <pre><code>Invoke-Command -ComputerName serverName -ScriptBlock {Get-Process} -Credential $credential
  </code></pre>
  
  <p>However this runs in this default directory for some reason - <code>c:\users\username\documents</code></p>
  
  <p>My actual situation is little different. I have got a powershell script (<code>Test.ps1</code>) sitting here:</p>
  
  <pre><code>C:\Data\Shared\Installation
  </code></pre>
  
  <p>I want to run this script remotely. I tried different things inside the ScriptBlock but it always gives an error. Looks like a syntax issue. For example I tried this:</p>
  
  <p><code>Invoke-Command -ComputerName serverName -ScriptBlock {cd "C:\Data\Shared\Installation" ./Test.ps1} -Credential $credential</code> </p>
  
  <p>but this gives the following error</p>
  
  <pre><code>A positional parameter cannot be found that accepts argument './Test.ps1'.
  </code></pre>
  
  <p>Just need some help regarding this. Thanks.</p>
  
  <p>Edit</p>
  
  <p><img src="https://i.stack.imgur.com/3Kees.png" alt="enter image description here"></p>
  
  <p>Edit 2</p>
  
  <p>Yes thanks for the comment (which has disappeared now) - putting a semi colon after the path works. Thanks for the help.</p>