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:
and write the following command in PowerShell and hit enter inside the PowerShell.
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:
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:
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:
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 Get–Host. 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.