0

How do I get the current path of the currently executing command or script?

Tried the following script:

$scriptpath = $MyInvocation.MyCommand.Path
write-host $scriptpath

and calling it like so:

 invoke-command -computername localhost -filepath .\test.ps1

Also tried the following but get a blank line:

invoke-command -scriptblock { write-host $MyInvocation.MyCommand.Path }
jaffa
  • 26,770
  • 50
  • 178
  • 289
  • answer: http://stackoverflow.com/a/5220517/520612 – CB. Oct 04 '13 at 12:51
  • possible duplicate of [Get script directory in PowerShell when script is invoked with Invoke-Command](http://stackoverflow.com/questions/5219461/get-script-directory-in-powershell-when-script-is-invoked-with-invoke-command) – Emperor XLII Nov 02 '13 at 23:04

1 Answers1

0

Have you tried using $pwd for getting the path?

Adil Hindistan
  • 6,351
  • 4
  • 25
  • 28