Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • 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 2012
    • 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?

November 3, 2020 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 Version Note
PowerShell 1.0 Can be installed manually on Windows Server 2003 SP1 and Windows XP
PowerShell 2.0 Windows Server 2008 R2 and Windows 7
PowerShell 3.0 Windows 8 and Windows Server 2012
PowerShell 4.0 Windows 8.1 and Windows Server 2012 R2
PowerShell 5.0 Preinstalled on Windows 10 RTM and automatically updated to 5.1 via Windows Update
PowerShell 5.1 It is built into Windows 10 (starting with Build 1709) and Windows Server 2016
PowerShell Core 6.0 and 6.1 It 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.0 It 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
Reset Local Group Policy Settings in Windows
next post
Compress, Defrag and Optimize MariaDB/MySQL Database

Related Reading

Enable Internet Explorer (IE) Compatibility Mode in Microsoft...

January 27, 2023

Finding Duplicate E-mail (SMTP) Addresses in Exchange

January 27, 2023

How to Disable or Uninstall Internet Explorer (IE)...

January 26, 2023

How to Delete Old User Profiles in Windows?

January 25, 2023

How to Stop Automatic Upgrade to Windows 11?

January 18, 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

  • Finding Duplicate E-mail (SMTP) Addresses in Exchange

    January 27, 2023
  • How to Delete Old User Profiles in Windows?

    January 25, 2023
  • How to Install Free VMware Hypervisor (ESXi)?

    January 24, 2023
  • How to Enable TLS 1.2 on Windows?

    January 18, 2023
  • Allow or Prevent Non-Admin Users from Reboot/Shutdown Windows

    January 17, 2023
  • Fix: Can’t Extend Volume in Windows

    January 12, 2023
  • Wi-Fi (Internet) Disconnects After Sleep or Hibernation on Windows 10/11

    January 11, 2023
  • Adding Trusted Root Certificates on Linux

    January 9, 2023
  • Fix: The Requested Certificate Template is Not Supported by This CA

    January 9, 2023
  • How to Remove Hidden/Ghost Network Adapters in Windows?

    December 29, 2022

Follow us

woshub.com

ad

  • Facebook
  • Twitter
  • RSS
Popular Posts
  • Installing RSAT Administration Tools on Windows 10 and 11
  • Get-ADUser: Find Active Directory User Info with PowerShell
  • How to Hide Installed Programs in Windows 10 and 11?
  • Managing Printers and Drivers with PowerShell in Windows 10 / Server 2016
  • How to Create a UEFI Bootable USB Drive to Install Windows 10 or 7?
  • PowerShell: Get Folder Sizes on Disk in Windows
  • Deploy PowerShell Active Directory Module without Installing RSAT
Footer Logo

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


Back To Top