How do you make cmdlet run when sessions is closed?

This topic contains 1 reply, has 2 voices, and was last updated by  Don Jones 3 years, 9 months ago.

  • Author
  • #16061



    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.


  • #16062

    Don Jones

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

    Drawing from 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.