How can I get the current PowerShell executing file?

前端 未结 10 1736
挽巷
挽巷 2020-12-07 15:04

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         


        
10条回答
  •  北荒
    北荒 (楼主)
    2020-12-07 15:46

    If you only want the filename (not the full path) use this:

    $ScriptName = $MyInvocation.MyCommand.Name
    

提交回复
热议问题