How do you make cmdlet run when sessions is closed?

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Don Jones Don Jones 2 years, 5 months ago.

  • Author
    Posts
  • #16061
    Profile photo of GS
    GS
    Participant

    Hello,

    During JEA presentation Jeffrey Snover asnwered to one of the questions from audience that there is a way to attach to closing session event somehow during start up profile. He did not go into details but I'm wondering what exactly I need to be researching to find how it's supposed to be done? I beleive this is built in functionality into standard PS endpoint and not something specific what JEA is added.

    Greg

  • #16062
    Profile photo of Don Jones
    Don Jones
    Keymaster

    So... yes and no. The session itself can't respond to itself closing.

    Drawing from http://stackoverflow.com/questions/8353581/how-to-handle-close-event-of-powershell-window-if-user-clicks-on-closex-butt a bit.

    But this is (nominally) C# programming, because if PowerShell isn't running, PowerShell can't do stuff. This is the thing Snover was talking about, at least (I just pinged him). It's a little out of scope for us to help you with here, but the StackOverflow post might be a starting point if you're up with the C# side of things.

    Now, there are probably some hacky workarounds I could think of, but they'd all come with some caveats.

You must be logged in to reply to this topic.