Close PowerShell Session with a keyboard shortcut


I love to work with shortcuts and to “TAB” my way through programs. So it always bothers me that I couldn’t close my PowerShell Console with a keyboard shortcut…

But thanks to a suggestion by Jason Stangroome and Bartek Bielawski (see here) this isn’t a problem anymore.

So I just added this line of code to my PowerShell (Console) Profile Script:

Set-PSReadlineKeyHandler -Chord Ctrl+D -Function DeleteCharOrExit

And now I can close my console window by hitting Ctrl and D. Of course, you could also use Alt + F4 or any other combination you like 😉


BTW: there are many more options for -Function besides DeleteCharOrExit – check it out by using TAB or Ctrl and Space.

Leave A Comment

CAPTCHA ImageChange Image