PowerShell is a type of command prompt that is more sophisticated. It comes with a large number of ready-to-use functions or cmdlets and the ability to leverage the.NET framework/C# in a variety of instances. PowerShell ISE is a graphical user interface for editing and testing scripts on Windows.
While many commands run on the command prompt would work on PowerShell, there are specialized scripts that will only work on Windows PowerShell.
In this article, Iâll guide you through the many PowerShell versions available, as well as how to determine which PowerShell version you have installed on your pc.
You would be introduced to running the most rudimentary scripts on PowerShell.
Letâs get right into it!
What are the Different Powershell Versions
PowerShell Versions 1 and 2
In November 2006, Windows XP SP2, Windows Server 2003 SP1, and Windows Vista were the original Windows versions for which PowerShell was published. Windows 7 and Windows Server 2008 R2 are included in the second version.
PowerShell 2.0 is also available as a standalone program for Windows XP Service Pack 3, Windows Server 2003 Service Pack 2, and Windows Vista Service Pack 1.
PowerShell Version 3
Microsoft released PowerShell 3.0 with Windows 8, which may also be deployed on Windows 7 Service Pack 1, Windows Server 2008 Service Pack 1, and Windows Server 2008 R2 Service Pack 1. There is no support on Windows XP by PowerShell 3.0.
PowerShell Version 4
PowerShell 4.0 is included in Windows 8.1, the successor to Windows 8. Itâs also offered on Windows 7 Service Pack 1, Windows Server 2008 Service Pack 1, and Windows Server 2008 R2 Service Pack 1.
PowerShell Version 5
Version 5 of PowerShell Windows Management Framework)Â 5.0 includes PowerShell 5.0. On February 24, 2016, the final version was released. Chocolateyâs repository-based applications were now supported by OneGet PowerShell cmdlets, as well as the ability to handle layer 2 network switches.
Along with the Windows 10 Anniversary Update, PowerShell 5.1 was launched. On January 19, 2017, it was made accessible to users of Windows 7, its server versions; Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, as well as Windows Server 2012 R2.
The applicationâs editions were implemented in PowerShell 5.1. The Core edition includes Windows Server 2016 Nano Server, whereas the Desktop edition is aimed at regular client and server editions of the operating system.
PowerShell Version 6
PowerShell Core was initially released on August 18, 2016, along with Microsoftâs intention to make the software cross-platform, independent of Windows, open-source, and free.
It was made available to Windows, macOS, and Linux users on January 10, 2018. Every six months, Microsoft expects to deliver a small update to PowerShell Core 6.0. On September 13, 2018, PowerShell Core 6.1 was launched.
PowerShell Version 7
PowerShell 7.0 is a multi-platform (macOS, Windows, and Linux) open-source edition of PowerShell that is designed to handle more diverse environments and hybrid clouds.
Microsoft introduces several new features in this version, including:-
- ForEach-Object â Parallel Parallelization of pipelines
- A new set of operators
- A more dynamic but simpler error view, as well as the Get-Error cmdlet, to facilitate error analysis
- A compatibility layer that allows users to load modules into a Windows PowerShell session that is not explicitly launched
- The ability to directly execute DSC resources from PowerShell 7
PowerShell 7 is installed in a separate location from Windows PowerShell. This allows you to run Windows PowerShell 5.1 alongside PowerShell 7. PowerShell 7 is an in-place update for PowerShell Core 6.x.
PowerShell 7.0 is the first version of PowerShell to use .NET Core 3.1, which allows for much better native support with current Windows PowerShell modules.
This contains numerous Windows modules that need GUI capabilities, such as Out-GridView and Show-Command, and also several Windows role administration modules.
Different Ways to Find your PowerShell Version
Now we have covered the different PowerShell versions, follow the steps below to find out which precise version of Windows is installed on your computer.
1. Using Get-Host
The idea of hosts is used in PowerShell. The PowerShell engine is hosted by a program called a host. It isnât actually the PowerShell engine. PowerShell hosts are the code editor or PowerShell console with an integrated terminal.
A host can have an edition of PowerShell that is entirely 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 outputs a version number that appears to be the version of the PowerShell engine. This may very easily fool many.
Here, I performed Get-Host on Windows PowerShell 5.1 and it returned 5.1.19041.1151, as shown below. I am confident this very much seems to be a genuine version.
When using an integrated terminal to perform Get-Host, the version may not always be the same. Although the host will generally reflect the same engine version, this is not always the case.
Get Host on Remote Devices
When Get-Host is called on a local computer, it always returns the same version, but it never does on remote devices.
Letâs examine what happens if we use Invoke-Command to perform Get-Host on a distant Windows Server. Note that doing this would require a user name and password as shown below.
PowerShell v1 isnât supported on Windows Server 2016, according to my research.
Using Get-Host for everything is a terrible idea.
2. Using $host.Version command to Check Powershell Version
$host.Version as a reference is another method for determining the Powershell version or look up the version number. The $host variable is a default variable that produces the same results as Get-Host.
This technique isnât particularly unique. It is the same as if you were to execute Get-Host.
Using $host.Version On Remote Computers
With $host.Version, youâll get the same results as with Get-Host when using PowerShell Remoting.
3. Using Registry to Check Powershell Version
You may also check the registry if you donât want to launch PowerShell. This is in fact an efficient way to check your PowerShell version.
The version of PowerShell is stored in the registry key path HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine as a value. Get-ItemProperty may be used to reference the PowerShellVersion value in this registry entry.
Using Different Tools
You wonât need to use PowerShell to determine the edition if you utilize the registry. You can use the (CMD) command prompt or another tool that can read your registry to perform commands.
Using the Registry Method on Remote Computers
The computer registry is static, and neither the data nor the location of the registry will change. You may rest certain that whatever displays locally will match what you see remotely.
4. Using $PSVersionTable.PSVersion command to Check Powershell Version
The final and last way is to make use of the $PSVersionTable automatic variableâs PSVersion attribute. The PowerShell engine will be represented by this technique.
The automatic variable $PSVersionTable is a read-only hash table that delivers data about the PowerShell engine version. Not only does this automatic variable return the version, but it also returns PSEdition. Depending on the version of PowerShell being used, this property can be either Core or Desktop.
Using $PSVersionTable command on Remote Computers
The automated variable $PSVersionTable is as precise remotely as it is locally. Enclosing $PSVersionTable.PSVersion in a scriptblock and running it on a remote machine returns the same version.
Final Thoughts on PowerShell Versions
Youâve learned how to verify the edition of PowerShell you have 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 you use $PSVersionTable.
PSVersion. Every one of the methods may appear to be identical to the PowerShell engine version, but they may not necessarily be.
Of course, I would love to know what methods you use to verify your PowerShell version. If there is something I have left out, I would love to know. You can always drop it in the comments below.