Как узнать какая версия PowerShell установлена?
17.11.2021
itpro
PowerShell, Windows 10, Windows Server 2012 R2
комментариев 6
В этой статье мы рассмотрим какие версии PowerShell существуют, в чем отличие Windows PowerShell от PowerShell Core и как узнать, какая версия PowerShell установлена на локальном или удаленных компьютерах.
История версии PowerShell, PowerShell Core
По умолчанию PowerShell устанвлен во всех версиях Windows, начиная с Windows 7 SP1 и Windows Server 2008 R2 SP1. В следующей таблице представлен список актуальных версий PowerShell:
| Версия PS | Примечание |
| PowerShell 1.0 | Можно было установить вручную в Windows Server 2003 SP1 и Windows XP |
| PowerShell 2.0 | Предустановлен в Windows Server 2008 R2 и Windows 7 |
| PowerShell 3.0 | Установлен в Windows 8 и Windows Server 2012 |
| PowerShell 4.0 | Предустановлен в Windows 8.1 и Windows Server 2012 R2 |
| PowerShell 5.0 | Предустановлен в Windows 10 RTM, и автоматически обновляется до 5.1 через Windows Update |
| PowerShell 5.1 | Встроен в Windows 10 (начиная с билда 1709) и Windows Server 2016 |
| PowerShell Core 6.0 и 6.1 | Следующая кроссплатформенная версия PowerShell (основана на .NET Core), которую можно установить не только во всех поддерживаемых версиях Windows, но и в MacOS, CentOS, RHEL, Debian, Ubuntu, openSUSE |
| PowerShell Core 7.0 | Самая последняя версия PowerShell, вышедшая в марте 2020 (в новом релизе выполнен переход с .NET Core 2.x на 3.1) |
Стоит обратить внимание, что последние 2 года Microsoft приостановила развитие классического Windows PowerShell (выпускаются только исправления ошибок и безопасности) и сфокусировалась на открытом кроссплатформенном PowerShell Core. В чем отличия Windows PowerShell от PowerShell Core?
- Windows PowerShell основан на NET Framework (например, для PowerShell 5 требуется .NET Framework v4.5, нужно убедиться что он установлен). PowerShell Core основан на .Net Core;
- Windows PowerShell работает только на ОС семейства Windows, а PowerShell Core является кроссплатформенным и будет работать в Linux;
- В PowerShell Core нет полной совместимости с Windows PowerShell, однако Microsoft работает на улучшением обратной совместимости со старыми командлетами и скриптами (перед переходом на PowerShell Core рекомендуется протестировать работу старых PS скриптов). В PowerShell 7 обеспечивается максимальная совместимсть с Windows PowerShell.
- Редактор PowerShell ISE нельзя использовать для отладки скриптов PowerShell Core (но можно использовать Visual Studio Code)
- Т.к. Windows PowerShell более не развивается, рекомендуется постепенно мигрировать на PowerShell Core.
Как узнать версию PowerShell из консоли?
Самый простой способ определить какая версия PowerShell у вас установлена с помощью команды:

Можно получить только значении версии:
(в этом примере мы получили версию PSVersion 2.0 с чистого Windows Server 2008 R2)

Команда $PSVersionTable корректно работает в PowerShell Core на различных операционных системах.
Также можно узнать установленную версию PowerShell через реестр. Для этого нужно получить значение параметра PowerShellVersion из ветки реестра HKLM\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine с помощью Get-ItemProperty
(Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine -Name ‘PowerShellVersion’).PowerShellVersion

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

Для определения установленной версии PowerShell Core нужно использовать команду:
(Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShellCore\InstalledVersions* -Name ‘SemanticVersion’).SemanticVersion
Получаем версию PowerShell на удаленных компьютерах
Для получения версии PowerShell на удаленных компьютерах нужно использовать значение переменной окружения $PSVersionTable или получать данные непосредственно из реестра. Другие способы могут возвращать некорректные данные.
Вы можете получить версию PowerShell с удаленного компьютера с помощью команды Invoke-Command:

Invoke-Command -ComputerName dc01 -ScriptBlock <$PSVersionTable.PSVersion>-Credential $cred
Можно получить установленные версии PowerShell с нескольких компьютеров таким скриптом (их список сохранен в текстовом файле):
Invoke-Command -ComputerName (Get-Content C:\PS\servers.txt) —
ScriptBlock <$PSVersionTable.PSVersion>| Select PSComputerName, @
Либо можно получить список компьютеров домена через Get-ADComputer и получить версию PowerShell на них:
$adcomputer=(Get-ADComputer -Filter ‘operatingsystem -like «*Windows server*» -and enabled -eq «true»‘ -SearchBase ‘OU=servers,dc=winitpro,dc=ru’ ).Name
Invoke-Command-ComputerName $adcomputer -Scriptblock <$PSVersionTable.psversion>-ErrorAction SilentlyContinue
Если ваш скрипт PoweShell использует специальный функционал определенной версии PS, вы можно принудительно переключиться в режим другой версии PowerShell. Например, для запуска консоли в режиме PowerShell v3, выполните (должен быть установлен .Net Framework 3.5):
PowerShell.exe -version 3
Определение версии PowerShell может быть важно при выполнении скриптов и запуске команд, которые используют командлеты или специальные возможности определенной версии PS. Если вы хотите в скрипте PS определить какая версия PowerShell установлена, и в зависимости от этого использовать разные командлеты, вы можете использовать такой скрипт:
$ps_version = $PSVersionTable.PSVersion.major
if ( $ps_version -eq «2” )
<
write «Вы используете Powershell 2.0»
>
elseif ( $ps_version -eq «5» )
<
write » Вы используете Powershell 5″
>
В следующей статье мы рассмотрим, как обновить версию PowerShell в Windows.
Предыдущая статья Следующая статья
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.
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) |
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?
- 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;
- Windows PowerShell works only in Windows operating systems, while PowerShell Core is cross-platform and can work in Linux as well;
- 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;
- You cannot use the PowerShell ISE Editor to edit PowerShell Core scripts (but Visual Studio Code can be used);
- 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:
Check the Version property value.

You can get the PowerShell version value only:
(in this example we got PSVersion 2.0 in clean Windows Server 2008 R2)

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

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

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
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, @
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
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.
Как узнать версию PowerShell в Windows 10, 8.1, 8, 7

В данной статье показаны действия, с помощью которых можно узнать установленную версию Windows PowerShell в операционных системах Windows 10, 8.1, 8, 7.
PowerShell — это оболочка командной строки с поддержкой задач и язык скриптов на основе платформы .NET.
PowerShell позволяет системным администраторам и опытным пользователям быстро автоматизировать задачи для управления операционной системой и поэтому всегда рекомендуется убедиться, что ваша система использует последнюю версию PowerShell.
Чтобы узнать установленную версию PowerShell, запустите консоль Windows PowerShell любым из способов и выполните следующую команду:
В строке PSVersion вы увидите версию PowerShell.

Также, чтобы узнать версию PowerShell, можно использовать дополнительные команды:
Результат выполнения команд показан на скриншоте ниже.

Ниже приведены версии, которые устанавливаются по умолчанию в соответствии с версией Windows:
Determine installed PowerShell version
How can I determine what version of PowerShell is installed on a computer, and indeed if it is installed at all?
![]()
22 Answers 22
Use $PSVersionTable.PSVersion to determine the engine version. If the variable does not exist, it is safe to assume the engine is version 1.0 .
Note that $Host.Version and (Get-Host).Version are not reliable — they reflect the version of the host only, not the engine. PowerGUI, PowerShellPLUS, etc. are all hosting applications, and they will set the host’s version to reflect their product version — which is entirely correct, but not what you’re looking for.
I would use either Get-Host or $PSVersionTable. As Andy Schneider points out, $PSVersionTable doesn’t work in version 1; it was introduced in version 2.
![]()
You can look at the built in variable, $psversiontable . If it doesn’t exist, you have V1. If it does exist, it will give you all the info you need.
![]()
![]()
To determine if PowerShell is installed, you can check the registry for the existence of
and, if it exists, whether the value is 1 (for installed), as detailed in the blog post Check if PowerShell installed and version.
To determine the version of PowerShell that is installed, you can check the registry keys
To determine the version of PowerShell that is installed from a .ps1 script, you can use the following one-liner, as detailed on PowerShell.com in Which PowerShell Version Am I Running.
The same site also gives a function to return the version:
![]()
You can directly check the version with one line only by invoking PowerShell externally, such as from Command Prompt
According to @psaul you can actually have one command that is agnostic from where it came (CMD, PowerShell or Pwsh). Thank you for that.
I’ve tested and it worked flawlessly on both CMD and PowerShell.

![]()
![]()
You can verify that Windows PowerShell version installed by completing the following check:
-
Click Start, click All Programs, click Accessories, click Windows PowerShell, and then click Windows PowerShell.
In the Windows PowerShell console, type the following command at the command prompt and then press ENTER:
You will see output that looks like this:
![]()
According to the linked page:
Depending on any other registry key(s), or version of PowerShell.exe or the location of PowerShell.exe is not guaranteed to work in the long term.
To check if any version of PowerShell is installed, check for the following value in the registry:
- Key Location: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1
- Value Name: Install
- Value Type: REG_DWORD
- Value Data: 0x00000001 (1
To check whether version 1.0 or 2.0 of PowerShell is installed, check for the following value in the registry:
- Key Location: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine
- Value Name: PowerShellVersion
- Value Type: REG_SZ
- Value Data: <1.0 | 2.0>
I found the easiest way to check if installed was to:
- run a command prompt (Start, Run, cmd , then OK)
- type powershell then hit return. You should then get the PowerShell PS prompt:
You can then check the version from the PowerShell prompt by typing $PSVersionTable.PSVersion :
Type exit if you want to go back to the command prompt ( exit again if you want to also close the command prompt).
![]()
$host.version is just plain wrong/unreliable. This gives you the version of the hosting executable (powershell.exe, powergui.exe, powershell_ise.exe, powershellplus.exe etc) and not the version of the engine itself.
The engine version is contained in $psversiontable.psversion . For PowerShell 1.0, this variable does not exist, so obviously if this variable is not available it is entirely safe to assume the engine is 1.0, obviously.
![]()
![]()
The easiest way to forget this page and never return to it is to learn the Get-Variable :
There is no need to remember every variable. Just Get-Variable is enough (and «There should be something about version»).
![]()
![]()
PowerShell 7
The accepted answer is only appropriate if one version of PowerShell is installed on a computer. With the advent of PowerShell 7, this scenario becomes increasingly unlikely.
Microsoft’s documentation states that additional registry keys are created when PowerShell 7 is installed:
Beginning in PowerShell 7.1, the [installer] package creates registry keys that store the installation location and version of PowerShell. These values are located in HKLM\Software\Microsoft\PowerShellCore\InstalledVersions\<GUID> . The value of <GUID> is unique for each build type (release or preview), major version, and architecture.
Exploring the registry in the aforementioned location reveals the following registry value: SemanticVersion . This value contains the information we seek.
On my computer it appears like the following:

As you can see, the version of PowerShell 7 installed on my computer is 7.1.3. If PowerShell 7 is not installed on the target computer, the key in its entirety should not exist.
As mentioned in the Microsoft documentation, the registry path will be slightly different dependent on installed PowerShell version.
Part of the key path changing could pose a challenge in some scenarios, but for those interested in a command line-based solution, PowerShell itself can handle this problem easily.
The PowerShell cmdlet used to query the data in this registry value is the Get-ItemPropertyValue cmdlet. Observe its use and output as follows (note the asterisk wildcard character used in place of the part of the key path that is likely to change):