Note: PowerShell 1.0
I\'d like to get the current executing PowerShell file name. That is, if I start my session like this:
powershell.exe .\\myfile.ps
If you are looking for the current directory in which the script is being executed, you can try this one:
$fullPathIncFileName = $MyInvocation.MyCommand.Definition
$currentScriptName = $MyInvocation.MyCommand.Name
$currentExecutingPath = $fullPathIncFileName.Replace($currentScriptName, "")
Write-Host $currentExecutingPath