How do you make cmdlet run when sessions is closed?

Welcome Forums General PowerShell Q&A How do you make cmdlet run when sessions is closed?

This topic contains 1 reply, has 2 voices, and was last updated by

 
Keymaster
4 years, 8 months ago.

  • Author
    Posts
  • #16061
    GS

    Participant
    Points: 12
    Rank: Member

    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

    Keymaster
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    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.

The topic ‘How do you make cmdlet run when sessions is closed?’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort