How to Check the PowerShell Version?

Requirement: Get the PowerShell version.

How to Find the PowerShell version installed?

PowerShell is a powerful scripting language that enables you to automate tasks, manage your environment, and more. The latest version of PowerShell has brought many new features. Hence, it’s important to know what version of PowerShell you have. Do you know how to check the PowerShell version you are running? Well, in this blog post, we’ll show you how to find out what PowerShell version you’re using in your system.

Why Checking PowerShell Version is Important?

Check the PowerShell Version

Before diving into the methods for checking the PowerShell version, it’s essential to understand why this information matters. Here are a few reasons why knowing your PowerShell version is essential:

  1. Compatibility: Newer PowerShell versions may introduce features or functionalities that are not available or not supported in previous versions. Knowing your PowerShell version helps ensure compatibility between your scripts and the environment in which they are executed.
  2. Security: Updating PowerShell to the latest version often includes security patches and vulnerability fixes that are critical for maintaining a secure environment.
  3. Performance: Newer versions of PowerShell often include performance enhancements, which can help improve the overall efficiency of your scripts and systems.

Windows PowerShell has gone through several major version releases over the years. Windows PowerShell originally shipped as version 1.0 on Windows server editions and desktop editions of client operating systems, and was eventually updated to version 5.1. With Windows 10 and Windows Server 2016, Microsoft introduced PowerShell Core, a cross-platform and open source rebuilt on .NET Core. PowerShell Core started at version 6.0 and has since been updated to version 7.2 as of November 2023.

Method 1: Using the $PSVersionTable Variable

The quickest and easiest way to check your PowerShell version is by utilizing the $PSVersionTable variable. This built-in variable contains information about the current PowerShell runtime environment, including the version number. Launch the PowerShell console and type the following command:

$PSVersionTable.PSVersion

These cmdlets retrieve the installed PowerShell version, including Major and Minor versions, build, and revision details. You can also use the “$PSVersionTable.PSVersion.Major” cmdlet to determine the major version of PowerShell installed. Similarly, to find out the PowerShell edition, use:

$PSVersionTable.PSEdition

Method 2: Using the Get-Host or $Host.Version Cmdlet

Another method to check your PowerShell version is by using the Get-Host cmdlet. This cmdlet retrieves information about the current host application, including the PowerShell engine’s version number.

Open PowerShell from the start menu >> Type:

Get-Host | Select-Object Version

PowerShell will display the version information similarly to the $PSVersionTable method, including a dot-separated by Major, Minor, Build, and Revision numbers.

Alternatively, you can use the automatic variable $Host to get the PowerShell engine version of the host:

$Host.Version
how to get powershell version

Method 3: Checking the Registry

The registry location “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine” stores the PowerShell version in the string “PowerShellVersion” on 64-bit Windows. You can open the Windows Registry Editor and navigate to this registry key to manually check this value to view PowerShell version:

powershell version check

Or you can query it directly in PowerShell:

Get-ItemPropertyValue -Path HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine -Name PowerShellVersion

This will return just the version number string.

How do I update PowerShell to the latest version? To upgrade to a newer version of PowerShell, refer: How to Update PowerShell Version?

Checking PowerShell version through Command Prompt

The Command Prompt is a command-line interface that allows you to interact with your computer. To check your PowerShell version using Command Prompt, follow these steps:

  1. Open Command Prompt by pressing the Windows key + R and typing “cmd” in the Run dialog box.
  2. Type the following command and press Enter:
powershell.exe $PSVersionTable.PSVersion

This command will display the version of PowerShell that you’re running.

Check the PowerShell version on remote computers

To check the PowerShell version on remote computers, you can use PowerShell remoting features, such as Invoke-Command or Enter-PSSession. Here are the steps and a basic script to help you achieve this:

Invoke-Command -ComputerName localhost -ScriptBlock {$PSVersionTable.PSVersion}

Make sure to set the computer name and PowerShell remoting is enabled with “Enable-PSRemoting -Force” on the remote machine.

Summary

In summary, knowing your PowerShell version is vital to ensure compatibility with scripts and modules and to take advantage of the latest features. There are several methods to check your PowerShell version, including using the PowerShell console, PowerShell ISE, Command Prompt, and Registry Editor. In this blog post, we have discussed various methods to check your PowerShell version, including the host variable, $PSVersionTable variable, and the Get-Host cmdlet methods.

Key Takeaways

  • Knowing your PowerShell version is essential for ensuring that your scripts and commands run correctly.
  • PowerShell comes pre-installed on Windows as part of Windows Management Framework and is available for installation on MacOS and Linux.
  • There are different methods for checking your PowerShell version, depending on your operating system. The above methods work on all Windows operating systems, including Windows XP, Windows 7, and Windows 11.
  • “pwsh –version” displays the version for PowerShell Core
  • Understanding PowerShell version numbers and compatibility is crucial when developing PowerShell scripts.
  • It’s essential to keep your PowerShell versions up to date to ensure compatibility and avoid potential issues.
Why is checking your PowerShell version important?

Different versions of PowerShell may have different features, compatibility, and bug fixes. By knowing your PowerShell version, you can determine if your scripts will work on different machines or if an upgrade is necessary.

How do I know what version of PowerShell I have?

If you are using Windows, PowerShell comes pre-installed. You can check your PowerShell version using PowerShell’s Get-Host cmdlet.

How do I find my PowerShell version on MacOS?

To check your PowerShell version on MacOS, open the Terminal app and type the following command: “Get-Host” and press Enter. This will also display the version number, which you can use for scripting purposes.

How do I check my PowerShell version on Linux?

To check the PowerShell version on Linux, you can open a terminal and run any of the following command: Get-Host, $host or $PSVersionTable.

How to check the PowerShell module version?

You can use the Get-Module cmdlet to check the version of a specific PowerShell module. E.g.,
(Get-Module -ListAvailable | Where-Object {$_.Name -eq "PnP.PowerShell"}).Version
Replace the PnP.PowerShell with your module name.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

Leave a Reply

Your email address will not be published. Required fields are marked *