Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / PowerShell / How to Check the PowerShell Version Installed?

May 10, 2023 PowerShellWindows 10Windows Server 2016

How to Check the PowerShell Version Installed?

In this article we will learn what PowerShell versions exist, what is the difference between Windows PowerShell and PowerShell Core, and how to check the PowerShell version installed on a local or remote computer.

Contents:
  • History and Versions of Windows PowerShell and PowerShell Core
  • How to Get PowerShell Version from the Console?
  • Check Version of PowerShell on Remote Computers

History and Versions of Windows PowerShell and PowerShell Core

PowerShell is installed by default in all Windows versions starting from Windows 7 SP1 and Windows Server 2008 R2 SP1. The following table shows the list of all PowerShell versions:

PS VersionNote
PowerShell 1.0Can be installed manually on Windows Server 2003 SP1 and Windows XP
PowerShell 2.0Windows Server 2008 R2 and Windows 7
PowerShell 3.0Windows 8 and Windows Server 2012
PowerShell 4.0Windows 8.1 and Windows Server 2012 R2
PowerShell 5.0Preinstalled on Windows 10 RTM and automatically updated to 5.1 via Windows Update
PowerShell 5.1It is built into Windows 10 (starting with Build 1709) and Windows Server 2016
PowerShell Core 6.0 and 6.1It is the next cross-platform PowerShell version (based on .NET Core) that may be installed on all supported Windows versions and on MacOS, CentOS, RHEL, Debian, Ubuntu, openSUSE
PowerShell Core 7.0It is the latest PowerShell version released in March, 2020 (.NET Core 3.1 is used in it instead of .NET Core 2.x)
You can manually install a newer PowerShell version in previous Windows versions. To do it, download and install the appropriate version of the Windows Management Framework (PowerShell is a part of it).

It is worth to note that in the last 2 years Microsoft suspended the development of classic Windows PowerShell (only bug fixes and security updates are released) and focused on open-source cross-platform PowerShell Core.

What’s the difference between Windows PowerShell and PowerShell Core?

  1. Windows PowerShell is based on .NET Framework (for example, PowerShell 5 requires .NET Framework v4.5, make sure that it is installed). PowerShell Core is based on .Net Core;
  2. Windows PowerShell works only in Windows operating systems, while PowerShell Core is cross-platform and can work in Linux as well;
  3. PowerShell Core is not fully compliant with Windows PowerShell, however, Microsoft is working on the improving of backward compatibility with earlier PS cmdlets and scripts. (it is recommended to test your old PS1 scripts before moving to PowerShell Core). PowerShell Core 7 provides the highest compatibility with Windows PowerShell;
  4. You cannot use the PowerShell ISE Editor to edit PowerShell Core scripts (but Visual Studio Code can be used);
  5. Since Windows PowerShell is no longer developed, it is recommended that you start migrating to PowerShell Core.

How to Get PowerShell Version from the Console?

The easiest way to find out which PowerShell version is installed on your computer is to use the command:

host

Check the Version property value.

The following screenshot was made in Windows 10 having PowerShell 5.1 installed by default, like in Windows Server 2016.

Find PowerShell Version in Windows

or

$PSVersionTable

You can get the PowerShell version value only:

$PSVersionTable.PSVersion.major

(in this example we got PSVersion 2.0 in clean Windows Server 2008 R2)

$PSVersionTable

The $PSVersionTable command correctly works in PowerShell Core in different operating systems.

You can also find out the installed PowerShell version through the registry. To do it, get the value of the PowerShellVersion parameter in the registry key HKLM\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine using Get-ItemProperty cmdlet:

(Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine -Name 'PowerShellVersion').PowerShellVersion

check powershell version in registry

The method described above works on Windows Server 2012/Windows 8 or newer.

In Windows Server 2008 R2/Windows 7, you can get the value of the registry parameter in another reg key:

(Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine -Name 'PowerShellVersion').PowerShellVersion

get 'PowerShellVersion' on windows server 2008 r2 / winn 7

To get the installed PowerShell Core version, use the following command:

(Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShellCore\InstalledVersions* -Name 'SemanticVersion').SemanticVersion

Check Version of PowerShell on Remote Computers

To check the PowerShell version on a remote host, use the value of the $PSVersionTable environment variable or get the information from the registry directly. Other methods may return incorrect data.

You can get the PowerShell version installed on a remote computer via PowerShell Remoting using the Invoke-Command cmdlet:

Invoke-Command -ComputerName mun-dc01 -ScriptBlock {$PSVersionTable.PSVersion} -Credential $cred
Get remote computer Powershell version using invoke-command

Major Minor Build Revision PSComputerName
----- ----- ----- -------- --------------
5 1 14393 3383 mun-dc01

You can get the installed PowerShell versions on multiple computers using the following script (the list of remote computers must be specified as a plain text file):

Invoke-Command -ComputerName (Get-Content C:\PS\host_list.txt) -
ScriptBlock{$PSVersionTable.PSVersion} | Select PSComputerName, @{N="PS Version";E={$_.Major}}

Or you can get a list of domain computers via Get-ADComputer and remotely check the PowerShell versions on them:

$adcomputer=(Get-ADComputer -Filter 'operatingsystem -like "*Windows server*" -and enabled -eq "true"' -SearchBase ‘OU=servers,OU=Munich,dc=woshub,dc=com’ ).Name
Invoke-Command-ComputerName $adcomputer -Scriptblock{$PSVersionTable.psversion} -ErrorAction SilentlyContinue

If your PowerShell script uses features of a specific PS version, you can force your script to switch to a different PowerShell version. For example, to run a console in PowerShell v3 mode, run this command (.Net Framework 3.5 must be installed):

PowerShell.exe -version 3

It may be important to know your PowerShell version if you run scripts or commands that use the cmdlets or features of a specific PS version. If you want to detect the installed PowerShell version in the script and use cmdlets based on it, you can run the following PS script:

$ps_version = $PSVersionTable.PSVersion.major
if ( $ps_version -eq "2” )
{
write "You are using Powershell 2.0"
}
elseif ( $ps_version -eq "5" )
{
write " You are using Powershell 5"
}

In the next article, we’ll take a look at how to update the PowerShell version in Windows.

0 comment
1
Facebook Twitter Google + Pinterest
previous post
Windows Couldn’t Connect to the GPSVC Service
next post
Compress, Defrag and Optimize MariaDB/MySQL Database

Related Reading

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

October 15, 2023

How to Query and Change Teams User Presence...

October 8, 2023

How to Use Ansible to Manage Windows Machines

September 25, 2023

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Get-ADUser: Find Active Directory User Info with PowerShell
  • How to Hide Installed Programs in Windows 10 and 11
  • PowerShell: Get Folder Sizes on Disk in Windows
  • Managing Printers and Drivers with PowerShell in Windows 10 / Server 2016
  • Deploy PowerShell Active Directory Module without Installing RSAT
  • Managing User Photos in Active Directory Using ThumbnailPhoto Attribute
  • Managing Saved Passwords Using Windows Credential Manager
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top