PowerShell Versions

Introduction

PowerShell is a command line shell and scripting utility, it has been a part of the Windows installation since Windows 7 in 2009.

It is unusual in that since 2016 it became open source and split into two branches, Desktop and Core. The Desktop 5.1 version comes bundled in Windows 10 and 11 along with the PowerShell Integrated Scripting Environment (ISE). The Core version which contains many exensions and improvements is available separately. ISE does not offer support for any version of PowerShell after 5.1 and Microsoft recommends using Visual Studio Code along with the PowerShell extension for editing.

In April 2025, I installed PowerShell Core 7.5 and wrote this page.


Installation

I installed the MSI package from the Microsoft site and during installation opted to have it updated using Windows Update.

I already use Visual Studio Code and have the Powershell extension for it installed.

If you need it Visual Studio Code is available for many operating systems.

Installing the PowerShell extension can be done in Visual Studio Code. Open the editor and click on the gear icon in the bottom left hand corner and click on the Extensions option. In the search box, type PowerShell and install the Microsoft extension.

Installing Visual Studio Code PowerShell extension

Installing Visual Studio Code PowerShell extension

Installing PowerShell Core does not change or interfere with the PowerShell Desktop already installed and both are available. PowerShell Desktop is installed at C:\Windows\System32\WindowsPowerShell\v1.0 and the executable is powershell.exe. PowerShell Core is installed at C:\Program Files\PowerShell\7 and the executable is pwsh.exe.

Both have their own environment variable and so can be executed from anywhere on the system.


Changing Version

Command Line

From the command prompt the version that is used in it can be changed by typing powershell for the Desktop (5.1) vesion or pwsh for the Core version. The version of PowerShell running can be checked by using $psversiontable at the PS prompt.

Running and checking the PowerShell version at the command prompt

Running and checking the PowerShell version at the command prompt

Te difference in the command to start PowerShell can be used to run a script with a particular version, for example powershell <path to script> or pwsh <path to script>

Visual Studio Code

Visual Studio Code (VS Code) can run either version of PowerShell, Desktop or Core. To see which version of PowerShell it is currently using, open or create a ps1 file. Then in the TERMINAL window at the bottom of the screen type $psversiontable. This should show which version is currently running, Desktop or Core.

Checking the PowerShell version in Visual Studio Code

Checking the PowerShell version in Visual Studio Code

Another method os seeing which version is currently running is to click on the curly braces {} at the bottom right of the Status Bar at the bottom of the VS Code window. This will result in a small pop-up appearing that shows the version of PowerShell is currently running.

Checking the PowerShell version in Visual Studio Code

Checking the PowerShell version in Visual Studio Code

To change the version of PowerShell that is running in VS Code the PowerShell Session Menu must be opened. To do this press the F1 keys or the Ctrl, Shift, and P keys together. In the search bar type PowerShell: Show Session Menu. Alternatively, click on the curly braces {} at the bottom right of the Status Bar at the bottom of the VS Code window and click on the Show PowerShell Session Menu link.

A menu like the one shown below will appear and let you choose which version to use.

Visual Studio Code PowerShell Session Menu

Visual Studio Code PowerShell Session Menu

Although my system is 64bit, PowerShell (x86) opens PowerShell 5.1 Desktop and PowerShell (x64) opens PowerShell 7.5 Core.

To show the PowerShell version number currently running click on the curly braces {} at the bottom right of the Status Bar at the bottom of the VS Code window and click on the thumbtack icon on the right. This will introduce a new icon to the Status Bar, showing the version number.

Visual Studio Code Status Bar PowerShell version icons

Visual Studio Code Status Bar PowerShell version icons

Clicking on the Status Bar PowerShell version icon will open the PowerShell Session Menu, allowing the version used to be changed.


Core Commands in Desktop

What happens if you use a command that is used in PowerShell Core but run it using PowerShell Desktop?

Take this simple script which checks to see if a web page is available and returns the server error code if it is not:

$StatusCode ="0"
$site = "https://example.com/anyoldpage.xyz";
$StatusCode = (Invoke-WebRequest -Uri $site -SkipHttpErrorCheck).StatusCode;
if($StatusCode -eq 200){
  Write-Host -Object "$site is up with status 200" -ForegroundColor Green
}
else{
  Write-Host -Object "$site is down with status $($StatusCode)" -ForegroundColor Cyan
}

The problem in the above code is the -SkipHttpErrorCheck switch. This was introduced in PowerShell 7 and not availble in PowerShell 5.1 Desktop.

If the script is run as PowerShell Core, then the following is output:

https://example.com/anyoldpage.xyz is down with status 404

The 404 is an error code returned by web servers and means the file or other resource cannot be found.

Running the same script as PowerShell 5.1 Desktop returns:

Invoke-WebRequest : A parameter cannot be found that matches parameter name 'SkipHttpErrorCheck'.
At C:\Scripts\error.ps1:5 char:48
+ ... tatusCode = (Invoke-WebRequest -Uri $site -SkipHttpErrorCheck).Status ...
+                                               ~~~~~~~~~~~~~~~~~~~
  + CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
  + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
     
https://example.com/anyoldpage.xyz is down with status 0

Which is not quite what is needed.


Sources & Resources

Download Visual Studio Code - Visual Studio Code
How can I select which version of PowerShell (5 or 7) is used when I run PowerShell code in VS Code? - Stack Overflow
How can I start Powershell script as noprofile in Visual Studio Code - Stack Overflow
Install PowerShell on Windows, Linux, and macOS - Microsoft Learn
Installing PowerShell on Windows - Microsoft Learn
Migrating from Windows PowerShell 5.1 to PowerShell 7 - Microsoft Learn
PowerShell - GitHub
PowerShell - Wikipedia
PowerShell in Visual Studio Code - Microsoft
The Windows PowerShell ISE - Microsoft Learn
Using Visual Studio Code for PowerShell Development - Microsoft Learn
Visual Studio Code on Windows - Visual Studio Code