0
votes

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 }
1

1 Answers

0
votes

Have you tried using $pwd for getting the path?