Steps to reproduce
Create file ./t - note the absence of extension .ps1 - with the content below and make it executable (chmod +x ./t).
#!/usr/bin/env powershell
'$PSCommandPath: ' + $PSCommandPath
'$MyInvocation.MyCommand.Path: ' + $MyInvocation.MyCommand.Path
'$MyInvocation: ' + ($MyInvocation | Out-String)
Both the following invocation methods, from bash, yield the behavior described below:
./t # invocation via shebang line
powershell ./t # implied -File
Expected behavior
$PSCommandPath and $MyInvocation.MyCommand.Path should reflect the script's file path, and $MyInvocation should be populated appropriately.
Actual behavior
$PSCommandPath:
$MyInvocation.MyCommand.Path:
$MyInvocation:
MyCommand : #!/usr/bin/env powershell
'$PSCommandPath: ' + $PSCommandPath
'$MyInvocation.MyCommand.Path: ' + $MyInvocation.MyCommand.Path
'$MyInvocation: ' + ($MyInvocation | Out-String)
BoundParameters : {}
UnboundArguments : {}
ScriptLineNumber : 0
OffsetInLine : 0
HistoryId : 1
ScriptName :
Line :
PositionMessage :
PSScriptRoot :
PSCommandPath :
InvocationName :
PipelineLength : 2
PipelinePosition : 1
ExpectingInput : False
CommandOrigin : Runspace
DisplayScriptPosition :
Environment data
PowerShell Core v6.0.0-beta.3 on macOS 10.12.5
PowerShell Core v6.0.0-beta.3 on Ubuntu 16.04.1 LTS
Steps to reproduce
Create file
./t- note the absence of extension.ps1- with the content below and make it executable (chmod +x ./t).Both the following invocation methods, from
bash, yield the behavior described below:Expected behavior
$PSCommandPathand$MyInvocation.MyCommand.Pathshould reflect the script's file path, and$MyInvocationshould be populated appropriately.Actual behavior
Environment data