The following S.O. question addresses the problem (when you're trying to figure it out from within a script). http://stackoverflow.com/questions/817198/how-can-i-get-the-current-powershell-executing-file
How would you do it if you were within a function.
The Example below works outside the definition of the function, just 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'
#EMPTY
echo "Path: $($MyInvocation.MyCommand.Path)"
#Prints the string definition of the function itself
echo "Definition: $($MyInvocation.MyCommand.Definition)"
echo '******************************'
}
myHelper