How to Check PowerShell Version?

There are many features that may only work in a specific PowerShell version. As a PowerShell administrator, you should know the exact version of PowerShell installed in the OS before running any script. In this tutorial, I will explain how to check the PowerShell version using several methods.

To check the PowerShell version in the Windows operating system, you can run this command: $PSVersionTable.PSVersion. This will work on Windows 11, Windows 10, and other operating systems.

There are also other methods you can use to check the PowerShell version.

Check PowerShell Version

Now, let me show you how to get the PowerShell version using different methods. Follow this along with the examples.

Method 1: Using $PSVersionTable

To check your PowerShell version, you can use the universal command: $PSVersionTable.

When you run this command, PowerShell displays a table with detailed version information, including PSVersion, PSEdition, GitCommitId, OS details, and more. This works in all PowerShell versions and across Windows, Linux, and macOS.

If you want just the version number without all the additional information, you can use:

$PSVersionTable.PSVersion

You can see the screenshot below. I executed the above command using VS code. It shows me the PowerShell version.

Check PowerShell Version

Sometimes you only need to know if you’re running PowerShell 5, 6, or 7 for basic compatibility checks. In these cases, you can get just the major version number by directly selecting it:

$PSVersionTable.PSVersion.Major

This command returns only the major version number (like 5 or 7).

Check out Run PowerShell Script From Command Line With Parameters

Method 2: Using Get-Host

The Get-Host cmdlet provides information about the current host program, including the version of PowerShell.

Get-Host

The output is shown in the screenshot below. It provides a lot of information, including the PowerShell version. This time, I executed the script using Windows PowerShell ISE.

Name             : Windows PowerShell ISE Host
Version          : 5.1.22621.2506
InstanceId       : aaa160fc-9465-4e39-84aa-2737f3b88c08
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-IN
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.Host.ISE.ISEOptions
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Here, the Version property indicates the PowerShell version.

How to Check PowerShell Version

Check out PowerShell Naming Conventions & Best Practices

Method 3: Using Get-Command

You can also use the PowerShell Get-Command cmdlets to get the PowerShell version. Below is the complete command.

(Get-Command powershell).Version

Method 4: Checking the Registry (Windows Only)

If you have knowledge about the Windows Registry, you can also check the PowerShell version there.

Here are the steps:

  1. Press Win + R, type regedit, and press Enter to open the Registry Editor.
  2. Navigate to the following path:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine
  3. Look for the PowerShellVersion entry, which will display the version.

Method 5: Using PowerShell Core on Linux or macOS

If you are using PowerShell Core on Linux or macOS, you can check the version using the pwsh command.

Here are the steps:

  1. Open Terminal.
  2. Type the following command and press Enter:pwsh --version
  3. The terminal will display the PowerShell version:PowerShell 7.4.0

Conclusion

In this tutorial, I have explained different methods to get the PowerShell version:

  • Using $PSVersionTable
  • Using Get-Host
  • Using Get-Command
  • Checking the Registry (Windows Only)
  • Using PowerShell Core on Linux or macOS

You may also like:

100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

FREE Download an eBook that contains 100 PowerShell cmdlets with complete script and examples.