To find the full filename and path of a running script use:
$MyInvocation.MyCommand.Definition
Just the filename
split-path $MyInvocation.MyCommand.Definition –Leaf
Just the path
split-path $MyInvocation.MyCommand.Definition -Parent
references:
https://stackoverflow.com/questions/817198/how-can-i-get-the-current-powershell-executing-file