A somewhat odd thing about PowerShell is that it may not be readily apparent which version you are running. Other Microsoft command line environments such as DOS and the Windows Command Prompt show you version information as soon as they launch. This is not the case with PowerShell.
In this article, you will learn how to check which PowerShell version you have.
Before moving ahead, I want to address one simple question: Why does the PowerShell version even matter? The reason is because newer versions often support cmdlets and syntax rules that simply do not exist in older versions. This is especially true of PowerShell 7.0, which introduced support for parallel operations, ternary operators, pipeline chain operators, and more. Such features do not exist in older PowerShell versions.
What Are the Commands to Check the PowerShell Version?
The way to check your PowerShell version depends on how you are running it.
Checking the PowerShell version on Windows
If you are running PowerShell within Windows, here is the primary command for checking your PowerShell version:
Get-Host | Select-Object Version
As a shortcut, you can instead type:
You can see examples of these commands in Figure 1.
Figure 1. There are two different ways that you can check your PowerShell version in Windows.
Checking the PowerShell version on Linux
Although PowerShell is probably best known as a command line interface for Windows, Microsoft has created a cross platform edition of PowerShell known as PowerShell Core. PowerShell Core is based on .NET Core (as opposed to the full .NET Framework) and supports far fewer cmdlets than Windows PowerShell. The one thing that PowerShell Core has going for it, however, is that it works with non-Windows environments such as Linux.
If you are running PowerShell Core on Linux, you can check the PowerShell version by opening the Terminal (if necessary) and entering pwsh --version. (Note that this command is meant to be run from the Linux command line, not from within PowerShell.) You can see what this looks like in Figure 2.
Figure 2. Linux lets you to check the PowerShell version using the pwsh --version command.
You can launch PowerShell (assuming that it is installed) by using the pwsh command. Once PowerShell is running, you can check its version by using the same commands used in Windows PowerShell. See Figure 3 for an example.
Figure 3. Once running, you can check the PowerShell version in Linux the same way that you do in Windows PowerShell.
What Are the PowerShell Version Numbers?
As of publishing this article, these are the existing versions of PowerShell.
Upgrade to a New Version of PowerShell
So, what happens if you check the PowerShell version and discover that you need a newer version?
One option is to run Windows Update. However, Windows Update will not always install the latest version of PowerShell. If you want the most recent PowerShell build, you will have to download it from Microsoft.
Microsoft offers different installation options, such as Winget, MSI packages, ZIP files, and even Microsoft Store packages. As such, you can choose the option that works best for your own situation.
Based on my experience, the easiest option is to download an MSI package. Just download and then double-click the MSI file. Windows will launch a GUI-based installer like the one shown in Figure 4.
Figure 4. The PowerShell MSI files include a GUI based installer.
Checking your PowerShell version isn’t something you will probably do daily, but it is important to know the version you have. As noted above, some PowerShell cmdlets will run only on specific PowerShell versions. Hence, if you are having trouble getting a command to work, you might check to make sure that you are running the required PowerShell version.