Get PowerShell Version

The best way to get PowerShell version is by running the $PSVersionTable or Get-Host commands. Using either of these commands, we can determine the installed PowerShell version on a computer. 

In this article, let us explore how to check the PowerShell version on various windows operating systems.

How to Get PowerShell Version on windows?

There are multiple ways to check the Powershell version installed on your machine. 

Method 1: Using $PSVersionTable

The $PSVersionTable.PSVersion command is used to determine the engine version. It returns the Major, Minor, Build, and Revision in a tabular format as shown below.

$PSVersionTable.PSVersion

Output

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      19041  1682

We can also use $PSVersionTable to check the PowerShell version. It returns many other information such as CLRVersion, PSCompatibleVersions, BuildVersion, etc.

$PSVersionTable

Output

Name                           Value
----                           -----
PSVersion                      5.1.19041.1682
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1682
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Note: The $PSVersionTable was introduced in version 2. Hence it does not work on PowerShell version 1. 

Method 2: Using Get-Host 

The alternative way to get the PowerShell version is by using the Get-Host cmdlet. The Get-Host cmdlet gets an object representing the program hosting Windows PowerShell.

By default, it will return the Windows PowerShell version, Current region, Language settings of the host machine, and a lot of other information about the host.

Get-Host

Output

Name             : ConsoleHost
Version          : 5.1.19041.1682
InstanceId       : 9c392805-21f0-44cd-9b83-bdf0c97c9d88
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

We can also return the Major, Minor, Build, and Revision information using the (Get-Host).Version cmdlet as shown below.

(Get-Host).Version

Output

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      19041  1682

Method 3: Using $Host.Version

The $Host.Version outputs the same as the (Get-Host).Version or $PSVersionTable.PSVersion.

The $Host.Version is not a reliable cmdlet to determine the PowerShell version when you are running with remote machines as they reflect the version of the host but not the engine.

$Host
$Host.Version

Output

Name             : ConsoleHost
Version          : 5.1.19041.1682
InstanceId       : 9c392805-21f0-44cd-9b83-bdf0c97c9d88
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      19041  1682

From PowerShell 5.1 onwards, there are multiple editions of PowerShell that each run on a different .NET runtime. As of PowerShell 6.0, there are two editions of PowerShell as follows:

Desktop, which runs on .NET Framework. PowerShell 4 and below and PowerShell 5.1 are available for full-featured Windows editions like Windows Desktop, Windows Server, Windows Server Core, and most other Windows operating systems.

Core, which runs on .NET Core. PowerShell 6.0 is later installed side-by-side with earlier PowerShell releases on full-featured Windows editions, some reduced-footprint Windows editions such as Windows Nano Server and Windows IoT, or on non-Windows platforms such as Linux and macOS.

If you are running PowerShell 5.0 and above, you can determine the PowerShell edition type by running the $PSEdition cmdlet.

$PSEdition

Output

Desktop

Conclusion

We can determine the PowerShell version installed on windows by running the $PSVersionTable or Get-Host commands. From PowerShell 5.0, we have different editions of PS, and we can get the information by running the $PSEdition cmdlet.

Leave a Reply

Your email address will not be published.

Sign Up for Our Newsletters

Subscribe to get notified of the latest articles. We will never spam you. Be a part of our ever-growing community.

You May Also Like
Powershell Concatenate String

PowerShell Concatenate String

Table of Contents Hide Introduction to PowerShell Concatenate StringHow to Concatenate Strings and Variables in PowerShell#1. Expanding Strings#2. Substitution or string.Format approach#3 Join Operator Microsft PowerShell scripting is little different from…
View Post