pointers, solutions and scripts for the SQL DBA
not intended to replace msdn, common sense or oxford commas

Tuesday, October 03, 2017

VS Code: PowerShell and focusConsoleOnExecute

If you're used to the behavior of SSMS or PowerShell ISE where upon executing code in the script panel, your cursor stays in the script panel, then the behavior of Visual Studio Code's PowerShell default might be annoying. By default in Code, your cursor moves down to the PowerShell console terminal upon executing code.

Maybe that's your thing. If not, there's a preference you can change, immediately.

In Code, go to the File Menu -> Preferences to launch the User Settings screen. There's a setting to overwrite the default called powershell.integratedConsole.focusConsoleOnExecute, that's what you're looking for. Add it to the right-side of the Code settings window like this:
{ "powershell.integratedConsole.focusConsoleOnExecute": false,
}

It'll look like this:

The change takes place immediately.
Not using Code yet? Hop to! https://code.visualstudio.com/Download

My former long-ago colleague and PowerShell prize-winning guru Mike F Robbins has a good blog post and video getting you up to speed on Code, he discusses powershell.integratedConsole.focusConsoleOnExecute and more.