Powershell

How to check PowerShell version

PowerShell is a command-line application that comes as built-in support for Windows, and it can be installed on Linux and macOS as well. PowerShell can be used to perform all the GUI tasks on the computing machines.

Microsoft released the first version of PowerShell 1.0 which comprised 129 cmdlets for Windows-7. Currently, the PowerShell 7.2 is the latest Long Term Support release of the PowerShell which supports more than one thousand cmdlets.

This article demonstrates various methods to check the version of PowerShell.

How to check the version of the PowerShell

PowerShell provides thousands of cmdlets and functions to manage your machine from the terminal. Here, we have presented various cmdlets, and functions that can be used to check the version of the PowerShell.

How to use the $PSVersion variable in PowerShell

The $PSversionTable is a local variable and contains all the information about the PowerShell engine.

Open the PowerShell from the Start menu as administrator privileges:

Graphical user interface Description automatically generated

and write the following command in PowerShell and hit enter inside the PowerShell.

$PSVersionTable

Text Description automatically generated

The output shows that the version of the PowerShell is “5.1“. However, you can get other detailed information about the PowerShell such as its edition, the compatible versions, and so on.

Additionally, “$PSVersionTable” has a property “.PSVersion” which can be used to check the version of the PowerShell as follows:

$PSVersionTable.PSVersion

Graphical user interface, text, application Description automatically generated with medium confidence

The output is more detailed as it shows the Major release number, Minor, Build, and Revision.

How to use the Get-Host cmdlet in PowerShell

The Get-Host cmdlet allows you to get the information of the host that is managing the PowerShell engine. The Get-Host cmdlet and its properties can be used to get the version of the PowerShell.

The command provided below retrieves the version of the PowerShell:

Get-Host

Text Description automatically generated

The version of the PowerShell can be observed in the above output.

Moreover, the “.Version” property of the “Get-Host” cmdlet will provide detailed information about the PowerShell version:

(Get-Host).Version

Diagram Description automatically generated

Look at the output, the complete version is “5.1.19041.1645” where the first digit represents the Major release number followed by the Minor, Build, and Revision.

Conclusion

The version of PowerShell can be checked using the local variable $PSVersionTable and a cmdlet named GetHost. This article lists down the possible methods to check the version of the PowerShell. The $PSVersionTable prints the version as well as other information about the host. Get-Host cmdlet and its “.Version” property can be practiced to check the version of the PowerShell as well.

About the author

Adnan Shabbir