Powershell profile “on exit” event?

后端 未结 1 1548
误落风尘
误落风尘 2020-12-05 14:25

I\'m looking for a way to automatically do some clean up tasks when the PowerShell session quits. So for example in my profile file I start a process which needs to run in t

相关标签:
1条回答
  • 2020-12-05 15:17

    There is the Register-EngineEvent cmdlet which you can use to attach an event handler to the Exiting event:

    Register-EngineEvent PowerShell.Exiting -Action { ... }
    

    Note however, that this event will not be fired if you close the console window.

    0 讨论(0)
提交回复
热议问题