How can I get the current PowerShell executing file?

前端 未结 10 1713
挽巷
挽巷 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 16:07

    This can works on most powershell versions:

    (& { $MyInvocation.ScriptName; })
    

    This can work for Scheduled Job

    Get-ScheduledJob |? Name -Match 'JOBNAMETAG' |% Command
    

提交回复
热议问题