The following SO question solves the problem (when you try to understand it from a script).
How to get the current PowerShell executable?
How would you do it if you were within a function.
The example below works outside the function definition, not inside.
echo ''
echo '******** outside function scope'
echo "Path: $($MyInvocation.MyCommand.Path)"
echo "Definition: $($MyInvocation.MyCommand.Definition)"
echo '*******************************'
echo ''
function myHelper()
{
echo '******** inside function scope'
echo "Path: $($MyInvocation.MyCommand.Path)"
echo "Definition: $($MyInvocation.MyCommand.Definition)"
echo '******************************'
}
myHelper
source
share