What is the difference between [pwsh] and [Powershell Integrated Console] on VS Code?
Asked Answered
H

1

42

What is the difference between [pwsh] and [Powershell Integreted Console] on VS Code?
I usualy use pwsh.
Today, when I installed the powershell extension and then tried to update the powershell, the Powershell Integreted Console started up and found out. What is this?  

Halmstad answered 8/2, 2020 at 7:25 Comment(0)
A
56
  • pwsh[.exe] is the executable file name of PowerShell [Core] (v6+), the cross-platform edition of PowerShell built on .NET Core / .NET 5+; by contrast, powershell.exe is the executable name of the legacy Windows PowerShell edition (v5.1-), built on the Windows-only .NET Framework (v4.8-)

    • Windows PowerShell comes with Windows itself, whereas PowerShell [Core] must be installed on demand (on all supported platforms).[+]
  • VSCode (Visual Studio Code) has an integrated terminal (console) that can run any shell, such as cmd.exe, bash, or pwsh or powershell.

    • Shells that run in the integrated terminal by default have no special integration with the files being edited. They show by their executable file name in the dropdown list in the integrated terminal's toolbar; e.g.: enter image description here
  • By contrast, the PowerShell Integrated Console is a special shell that comes with the PowerShell extension and offers integration with PowerShell code being edited, notably to provide linting and debugging support, among other features.

    • The PowerShell Integrated Console starts on demand when you first open/activate an editor with PowerShell code in a session, and it shows as follows in the integrated terminal's toolbar: enter image description here

    • You can use the PowerShell extension's configuration to choose the specific PowerShell executable to use, which on Windows allows you to choose between running PowerShell [Core] (pwsh.exe) and Windows PowerShell (powershell.exe) in the PowerShell Integrated Console.

      • If a PowerShell [Core] version is installed and it is installed in a well-known location[*], it will be used by default; the fallback on Windows is Windows PowerShell. Since PowerShell [Core] versions can be installed side by side, you can switch between different versions, if installed.

      • If a PowerShell [Core] version in installed in a nonstandard location and is therefore not discovered automatically, you can tell the PowerShell extension where to find it, either via the Settings GUI or via settings.json, as shown in the linked topic and the bottom section of this answer.

      • Whenever the active tab is a PowerShell source-code file, the status bar in the bottom-right corner shows the PowerShell version that is being used if you however over or click on the {} icon; versions >= 6 imply PowerShell [Core].
        If configured, there's a separate icon that directly invokes the PowerShell session menu when clicked and which reflects the active version number - again, see the bottom section of this answer; e.g.: enter image description here


[+] as of v7.0; time will tell if PowerShell [Core] will ship with future versions of Windows, and perhaps even other platforms.

[*] From the linked docs: "This feature looks at a few well-known paths on different operating systems to discover install locations of PowerShell. If you installed PowerShell to a non-typical location, it might not show up initially in the Session Menu. You can extend the session menu by adding your own custom paths." If you use one of the official installers, the PowerShell extension should find your installation.

Aklog answered 9/2, 2020 at 1:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.