How To Check The Installed Version Of PowerShell

How To Check The Installed Version Of PowerShell

This article explains how to check the installed version of PowerShell.

Question

How can we discover which version of PowerShell we are running on?

Quick Answer

We can use the $PSVersionTable system variable:

$PSVersionTable.PSVersion

This will return an object with the installed version build numbers:

Long Answer

We can use $PSVersionTable to discover the versions of different components of PowerShell:

For example:

  • CLRVersion property shows the installed version of the CLR.
  • PSCompatibleVersions shows us what script versions we can run on the current installed versions.

Notably, the PSVersion shows the installed version of PowerShell:

Knowing this, we can then use this property to make decisions based on the installed version:

if ($PSVersionTable.PSVersion.Major -ge 4)
{
    "This is a supported version"
}
else
{
    throw "Please upgrade PowerShell to run this script."
}

Easy, isn’t it?

Jorge Candeias's Picture

About Jorge Candeias

Jorge helps organizations build high-performing solutions on the Microsoft tech stack.

London, United Kingdom https://jorgecandeias.github.io