How to Check your PowerShell Version (All the Ways!)

choubertsprojects

VPN offers!

1. NordVPN

2. Surfshark

3. ExpressVPN

Many reasons exist for the importance of PowerShell, but one reason is its ability to work across different platforms. The first step towards using PowerShell in your organization is knowing what version you have installed. Here are all the ways!

PowerShell is a command-line shell and scripting language. It is used by administrators and developers alike to automate tasks on Windows, Linux, and macOS computers. PowerShell commands are often the first thing you type when you want to get something done. The “how to check powershell version command” allows users to view their current PowerShell version as well as how many versions back it goes.

How to Check your PowerShell Version (All the Ways!)

There are a billion methods to perform the same thing with PowerShell (or close to it). This blog article will show you how to verify the PowerShell version on both local and remote systems. We’ll go through the terrible options as well as my personal recommendation.

There are a number of websites that demonstrate how to verify the version of Powershell. There was, however, no one who created a full list of all of them. That was something I resolved to fix.

Both Windows PowerShell and PowerShell Core should support all of these methods. These techniques should work in all versions of Windows PowerShell from 1.0 to PowerShell 7.

You may find out what version of PowerShell you’re running by using the following methods:

  1. The property (Get-Host).Version
  2. The $host.Version attribute is used to determine the version of a web server.
  3. The registrar’s office (Windows PowerShell only)
  4. PSVersionTable.PSVersion is a property in the $PSVersionTable class.

Let’s go through all of the many methods to determine the PowerShell version, starting with the least recommended and working our way up to the most recommended.

Get-Host

The idea of hosts is used in PowerShell. The PowerShell engine is hosted by a program called a host. It isn’t the PowerShell engine that is causing the issue. PowerShell hosts are the PowerShell console or a code editor with an integrated terminal.

A host may have a version of PowerShell that is totally self-contained. Many newbies may be misled by this. Allow me to demonstrate why.

When you use (Get-Host).Version, you’ll see that it returns a version number that appears to be the PowerShell engine version. It’s easy to be fooled by appearances.

I’ve run Get-Host on Windows PowerShell 5.1 and it returns 5.1.17134.858, as you can see below. This seems to be a genuine version.

PS51> (Get-Host).Version Major Minor Build Revision —– —– —– ——– 5 1 17134 858

However, the version of Get-Host in an integrated terminal is not always the same. Although the host normally represents the same version of the engine, this is not always the case.

Get-Host on remote computers to check Powershell version

When Get-Host is called on a local computer, it always returns the same version, but it never does on distant systems.

Let’s examine what happens if we use Invoke-Command to perform Get-Host on a remote Windows Server 2016 server.

PS51> Invoke-Command -ComputerName 10.0.0.5 -ScriptBlock {Get-Host} -Credential $cred Major Minor Build Revision PSComputerName —– —– —– ——– ————– 1 0 0 0 10.0.0.5

PowerShell v1 is not supported on Windows Server 2016, as far as I’m aware.

Using Get-Host for everything is a terrible idea.

Check the $host.Version command in Powershell.

$host is being referenced. Another approach to verify Powershell version is to use version. Get-Host delivers the same result as the $host variable, which is an automatic variable.

Using $host.Version as a referenceUsing $host.Version as a reference

This strategy isn’t particularly unique. It’s the same as if you ran Get-Host.

On remote computers, $host.Version

With $host.Version and PowerShell Remoting, you’ll get the same results as with Get-Host.

PS51> Invoke-Command -ComputerName 10.0.0.5 -ScriptBlock {$host.Version} -Credential $cred Major Minor Build Revision PSComputerName —– —– —– ——– ————– 1 0 0 0 10.0.0.5

Will Robinson, you’re in danger!

Registry

You may also check the registry if you don’t want to launch PowerShell. In the registry key path HKLM:SOFTWAREMicrosoftPowerShell3PowerShellEngine, the version of PowerShell is hidden. Get-ItemProperty may be used to access the PowerShellVersion value in this registry entry.

PS51> (Get-ItemProperty -Path HKLM:SOFTWAREMicrosoftPowerShell3PowerShellEngine -Name ‘PowerShellVersion’).PowerShellVersion 5.1.17134.1

As you can see, this version is identical to the others, except it does not have the revision.

PS51> [version](Get-ItemProperty -Path HKLM:SOFTWAREMicrosoftPowerShell3PowerShellEngine -Name ‘PowerShellVersion’).PowerShellVersion Major Minor Build Revision —– —– —– ——– 5 1 17134 1

Using Other Resources

You won’t need to use PowerShell to discover the version if you utilize the registry. You may use the command prompt or another tool that can read the registry to perform commands.

CMD> reg query HKLMSOFTWAREMicrosoftPowerShell3PowerShellEngine /v PowerShellVersion HKEY_LOCAL_MACHINESOFTWAREMicrosoftPowerShell3PowerShellEngine PowerShellVersion REG_SZ 5.1.17134.1

Remote Computers’ Registry

The register is static, and neither the values nor the location of the registry will change. You may be certain that what you see locally will match what you see remotely.

PS51> $scriptBlock = { [version](Get-ItemProperty -Path HKLM:SOFTWAREMicrosoftPowerShell3PowerShellEngine -Name ‘PowerShellVersion’).PowerShellVersion } PS51> Invoke-Command -ComputerName 10.0.0.5 -ScriptBlock $scriptBlock -Credential $cred Major Minor Build Revision PSComputerName —– —– —– ——– ————– 5 1 17763 1 10.0.0.5

It’s a good idea to show the same version locally and remotely. However, I have a better technique to demonstrate how to use the $PSVersionTable automatic variable.

$PSVersionTable may be used to check the Powershell version. PSVersion is a command that allows you to change the version of

The last and last way is to use the $PSVersionTable automatic variable’s PSVersion attribute. The PowerShell engine will always be represented by this technique.

PS51> $PSVersionTable.PSVersion Major Minor Build Revision —– —– —– ——– 5 1 17134 858

The automatic variable $PSVersionTable is a read-only hash table that delivers information about the PowerShell engine version. Not only does this automatic variable return the version, but it also returns PSEdition. This property may be either Core or Desktop, and it will provide you further information about the PowerShell edition you’re using.

output of $PSVersionTableoutput of $PSVersionTable

On remote computers, $PSVersionTable

The automated variable $PSVersionTable is as accurate locally as it is remotely. You can see in the example below that enclosing $PSVersionTable.PSVersion in a scriptblock and running it on a remote machine returns the same version.

PS> Invoke-Command -ComputerName 10.0.0.5 -ScriptBlock {$PSVersionTable.PSVersion} -Credential $cred Major Minor Build Revision PSComputerName —– —– —– ——– ————– 5 1 17763 592 10.0.0.5

Summary

You’ve learnt how to verify the version of PowerShell both locally and remotely in this blog article. I hope the first several techniques offered you some insight into which methods should not be used to verify the version!

I always advocate using $PSVersionTable. PSVersion. All of the other methods may seem to be comparable to the PowerShell engine version, but they may not necessarily be.

Please let me know if I missed anything in the comments. I’ll be happy to amend the post and credit you.

The “latest version of powershell” is a command-line tool that allows users to manage their computer. It also has a graphical user interface. The PowerShell version number is listed on the help menu at the bottom left corner of the window.

Related Tags

  • how to upgrade powershell version
  • how to update powershell version in windows 10
  • how to check powershell version in windows 10
  • powershell version 7
  • powershell version 5