$MyInvocation.PSCommandPath
unexpectedly returns $null
rather than the empty string when there is no calling script.
#23828
Labels
Needs-Triage
The issue is new and needs to be triaged by a work group.
Prerequisites
Steps to reproduce
$MyInvocation.PSScriptRoot
and$MyInvocation.ScriptName
, which is the older equivalent of$MyInvocation.PSCommandPath
, sensibly report''
, i.e. the empty string in case there is no calling script.Unexpectedly,
$MyInvocation.PSCommandPath
reports$null
instead in this situation.Not just for consistency with the other properties, but for consistency with PowerShell's general behavior of not using
$null
in string contexts, this should be fixed.However, given that there may be existing code that explicitly tests for
$null
, it should at least be documented.Expected behavior
Actual behavior
That is,
$MyInvocation.PSCommandPath
unexpectedly returned$null
.Error details
No response
Environment data
Visuals
No response
The text was updated successfully, but these errors were encountered: