title: Cannot bind argument to parameter 'Path' because it is null
body: <p>How do I get the current path of the currently executing command or script?</p>
  
  <p>Tried the following script:</p>
  
  <pre><code>$scriptpath = $MyInvocation.MyCommand.Path
  write-host $scriptpath
  </code></pre>
  
  <p>and calling it like so:</p>
  
  <pre><code> invoke-command -computername localhost -filepath .\test.ps1
  </code></pre>
  
  <p>Also tried the following but get a blank line:</p>
  
  <pre><code>invoke-command -scriptblock { write-host $MyInvocation.MyCommand.Path }
  </code></pre>