(Context)
So first it's important to note that both actually use pwsh
. While we do of course need a custom PSHost
in order to provide an integrated experience, most of the calls just go right back to the same implementation of whatever version of PowerShell you're running.
That said, here's a few benefits of using the PowerShell Integrated Console vs a non-integrated terminal:
When you hit a breakpoint in the debugger the PSIC is running in that context. So you can interactively inspect (and mutate) the state of the script you're running. You can also execute debugger commands from there:
s, stepInto Single step (step into functions, scripts, etc.)
v, stepOver Step to next statement (step over functions, scripts, etc.)
o, stepOut Step out of the current function, script, etc.
c, continue Continue operation
q, quit Stop operation and exit the debugger
d, detach Continue operation and detach the debugger.
k, Get-PSCallStack Display call stack
l, list List source code for the current script.
Use "list" to start from the current line, "list <m>"
to start from line <m>, and "list <m> <n>" to list <n>
lines starting from line <m>
<enter> Repeat last command if it was stepInto, stepOver or list
?, h displays this help message.
Because the PSIC and the editor pane share the same context, you can import modules, create variables/functions, etc and they will be reflected in intellisense
There are other extensions that can do something similar, but they all send selected text as direct input to the console. This can sometimes cause issues if your selected text must run as a unit of code (like if you have else
's that aren't cuddled) or if you have custom PSReadLine key handlers.
In the integrated console your selection is sent and processed by the language server so you can be sure that your selection is interpreted how you expect.
This is an automatic variable in the integrated console that lets you interact with the editor with code. This lets you do things like Get-ChildItem | Out-CurrentFile
to add text to the current editor from the console.