You may want to know the PowerShell version installed on your machine. While novice users may go to Programs in the Control Panel to check the PowerShell version, it’s often quite the disappointment when they don’t find PowerShell listed as a program there. Instead, you’ll need to resort to other methods to find the PowerShell version.
This article provides a comprehensive guide to checking the PowerShell version you’re running.
Introduction to PowerShell Versions
PowerShell has evolved from a Windows management tool to a versatile shell that can be used across different platforms. In particular, PowerShell Core 6.x and PowerShell 7.x turned it into a powerful, cross-platform automation and scripting framework.
PowerShell Versions Evolution from 1.0 to 7.x
In 2006, Microsoft launched PowerShell 1.0 as part of the .NET framework for the Windows operating system, including Windows XP (SP2), Windows Server 2003 (r2 SP1), and Windows Vista. It introduced cmdlets like Get-Process and Get-Service and was designed to automate tasks in Windows environments.
Version | Description |
---|---|
PowerShell 2.0 | PowerShell 2.0 came in 2009. Amongst other things, it introduced remoting (via WinRM) to run commands on remote machines and the Integrated Scripting Environment (ISE) application. |
PowerShell 3.0 | PowerShell 3.0, released in 2012, introduced workflows, new cmdlets and scheduled jobs for task automation. |
PowerShell 4.0 | PowerShell 4.0 (2013), 5.0 (2016), and 5.1 (2016) had improvements in cmdlets, performance, and DSC. Classes and Enums were added to the scripting language. With PowerShell 5.1, there was a shift towards open-source and PowerShell Core. |
PowerShell Core 6.x | Then PowerShell Core 6.x (2018) was open-sourced and moved to GitHub. It was cross-platform, running on Windows, macOS, and Linux. Not only that, but it was also built for heterogeneous environments and the hybrid cloud. |
PowerShell 7.x | PowerShell 7.x (2020) is the most recent version. It unifies Windows PowerShell and PowerShell Core into a single version stream, supports pipeline parallelization, and improves error handling amongst other things. |
Why identify the correct PowerShell version
Before you use PowerShell for your everyday tasks, one question you may ask is, what version of PowerShell do I have? Having an answer to this question is important because your PowerShell version determines what cmdlets and functions you can use. For this and many other reasons, you must identify which PowerShell version you need to manage your tasks.
- Compatibility. Some scripts or modules require specific cmdlets or features that are available only in the latest PowerShell version. Modern PowerShell versions support older scripts, but with deprecation warnings for outdated features.
- Accuracy in Results. Some PowerShell versions may not yield accurate results you’re looking for, such as when you must meet a specific requirement or prerequisite to run a command or load a module.
- Cross-Platform Support. For Linux or macOS, you need PowerShell Core or PowerShell 7.x.
- Advanced features. Older versions do not support the latest features, such as pipeline parallelism, ?? (null coalescing operator), and ForEach-Object -Parallel, that are available in PowerShell 7.x.
- Cloud and DevOps Integration. Recent PowerShell versions provide enhanced integration capabilities with cloud platforms, such as Azure, AWS), DevOps tools, and CI/CD pipelines, facilitating cloud-based management.
- Security Requirements. The latest PowerShell versions are recommended for security and compliance reasons.
- Environment Setup. To use tools or automations across the environment, knowing the version helps ensure compatibility across systems.
Differences between Windows PowerShell and PowerShell Core
Key differences between Windows PowerShell and PowerShell Core are:
Feature | Windows PowerShell | PowerShell Core |
Platform | Windows-only | Cross-platform (Windows, macOS, Linux) |
Version | Last major version: 5.1 | Ongoing releases (7.x and beyond) |
Framework | Based on .NET Framework | Based on .NET Core (now .NET) |
Release Model | Only bug/security fixes | Active development with new features |
Installation | Is pre-installed with Windows OS | Has to be downloaded separately from GitHub or package managers |
Backward Compatibility | Tight integration with Windows (e.g., WMI, COM) | May have limited Windows-specific features |
Performance | Faster in some Windows-native scenarios | Better performance on multiple platforms |
Module Compatibility | Supports many legacy modules | Some older modules may not be compatible |
Cloud/Container Support | Limited support for containers and cloud environments | Better support for containers and cloud |
Open Source | Proprietary | Open-source (MIT license) |
If you use legacy Windows-specific features or modules, Windows PowerShell is a better choice. But for cross-platform development and cloud-based workflows, PowerShell Core serves best.
How to Check PowerShell Version
Knowing the installed version of PowerShell is important for several practical reasons, as your version determines what cmdlets and functions are available for use. Different versions may offer varied support for different scripts, modules, and platforms. For smooth PowerShell operations, you must know the PowerShell version you are using, its limitations, and its core features.
How to check the PowerShell version is a simple task. The easiest way to check the PowerShell version is through PowerShell itself. You can show the PowerShell version you’re using, for example, via the PSVersionTable.PSVersion or the Get-Host cmdlet.
PowerShell Version Command: $PSVersionTable.PSVersion
This is the most reliable method to get your PowerShell version as it returns information specifically about the PowerShell engine version.
$PSVersionTable.PSVersion
This cmdlet displays the major, minor, and build (patch) version of the installed PowerShell. The revision number is displayed if applicable.
If you want to view more details than just the version, try the following cmdlet:
$PSVersionTable
$PSVersionTable shows several environment-specific properties in addition to the version.
- PSVersion – Shows the PowerShell version
- PSEdition – Shows whether it’s Desktop (Windows PowerShell) or Core (PowerShell Core / PowerShell 7+)
- WSManStackVersion – Shows the version of WS-Management (used for remoting)
- PSRemotingProtocolVersion – Remoting protocol version
- SerializationVersion – Used to maintain compatibility with older versions for remote sessions
How to Get PowerShell Version with Get-Host Command
A host is a program that hosts the PowerShell engine. And you can have a host with a version that is independent of PowerShell.
The following cmdlet outputs the PowerShell version you’re running, but then this version can be inaccurate as it reflects host version, not engine version.
Get-Host
Oftentimes, the PowerShell version matches that of the host. In addition to the host version, this cmdlet also displays the name of the host, current culture, and UI culture.
The Get-Host command does not work remotely and always returns version 1.0.0.0.
$Host and $Host.Version Commands
$host is an automatic variable that displays the same information as the Get-Host cmdlet.
$host
If you are looking for the PowerShell version, $host is not recommended for the same reasons as Get-Host. The same is true for $host.Version.
$host.Version
It displays the version of the host application that is running the current PowerShell session, though in a different format.
Registry Editor
You can check the PowerShell version through the Registry Editor in any of the following ways:
- Use the Get-ItemProperty cmdlet to query the registry for the installed PowerShell version.
- Go to Registry Editor and manually locate the paths for PowerShell version details.
Via Cmdlets
For PowerShell version 5
You can view the PowerShellVersion registry key with the ‘Get-ItemProperty’ cmdlet. It is as:
(Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine -Name 'PowerShellVersion').PowerShellVersion
For PowerShell version 7
If you have PowerShell 7 or later installed, use the following cmdlet:
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\PowerShellCore' | Select-Object -Property PSVersion
Manual method
You can get the PowerShell configuration and version information in the Registry Editor.
For PowerShell version 5
In the Registry editor, expand Computer > HKEY-LOCAL-MACHINE > SOFTWARE > Microsoft > PowerShell >3 > PowerShellEngine. In the adjacent pane, you will find information including the PowerShell version number.
For PowerShell version 7
If you have PowerShell 7 installed, go to the following path in the Registry Editor to check the version:
Computer > HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > PowerShellCore > InstalledVersions > 31ab5147-9a97-4452-8443-d9709f0516e1
Advanced Techniques for Version Identification
Find PowerShell Version on Remote Systems
Prerequisites
The following prerequisites must be met before you can check the PowerShell version on a remote machine.
- Windows Management Framework (WMF) is installed and enabled on the remote machine.
- WinRM (Windows Remote Management) is configured and running on both the local and remote machines.
Run ‘winrm quickconfig’ to prepare a machine to be remotely accessed via PowerShell. - You have the required permissions on the remote machine.
Check PowerShell version on a remote machine
Use the Invoke-Command cmdlet with $PSVersionTable to check the PowerShell version installed on a remote computer.
Invoke-Command ` -ComputerName WS16-DC1 ` -ScriptBlock { $PSVersionTable.PSVersion } ` -Credential $cred
Note:
- In this command, replace the ComputerName (WS16-DC1) with your specific computer name, and the credentials below $cred with a valid username and password.
- By using commas to separate values, you can effectively handle several remote computers at once.
In the above cmdlet:
- Invoke-Command is used to run commands on a remote computer.
- ComputerName WS16-DC1 specifies the name of the remote computer (WS16-DC1 in this case).
- ScriptBlock {$PSVersionTable.PSVersion} is the script block that is run on the remote computer to retrieve the PowerShell version information.
- Credential $cred specifies the credentials to authenticate on the remote computer, where $cred is an object that contains valid credentials (such as a username and password).
PowerShell Version Comparison Across Windows Operating Systems
This table lists the PowerShell versions pre-installed with different Windows operating systems:
PowerShell Version | Release Date | Windows OS Supported by Default |
PowerShell 1.0 | November 2006 | Windows Server 2003 SP1 Windows XP SP2 Windows Vista |
PowerShell 2.0 | October 2009 | Windows Server 2008 R2 Windows 7 |
PowerShell 3.0 | September 2012 | Windows Server 2012 Windows 8 |
PowerShell 4.0 | October 2013 | Windows Server 2012 R2 Windows 8.1 |
PowerShell 5.0 | February 2016 | Windows Server 2016 Windows 10 |
PowerShell 5.1 | August 2016 | Windows Server 2016 Windows 10 anniversary update |
PowerShell Core 6.0 | January 2018 | Windows Server 2012 R2 Windows Server 2012 Windows Server 2016 Windows 10 Windows 8.1 Windows 7 with Service Pack 1 |
PowerShell 5.1 is the last version installed by default on Windows clients and servers. It has been succeeded by PowerShell Core (now PowerShell 7), which is a separate product. It does not come pre-installed but has to be manually installed.
Installing a newer version does not replace the default pre-installed version. For example, PowerShell 7.x and Windows PowerShell 5.1 can co-exist.
Update or Install Newer PowerShell Versions
To stay up to date on Windows PowerShell 5.1 in Windows 10 and 11, always run system updates to keep your PC up to date.
PowerShell Core (version 7) is a different product from Windows PowerShell and must be installed manually via any of the following methods:
- Download and run the installer file
- Run a command from PowerShell on your computer
As a recommendation, keep both Windows PowerShell and PowerShell Core on your computer to get the most out of PowerShell. Beware that older scripts may not work in newer versions and current scripts may not work in older versions.
You can download and install a newer PowerShell version in any of these ways.
Install PowerShell Using Microsoft Store
On Windows 10 and Windows 11, open the Microsoft Store and search for PowerShell.
The latest version of the PowerShell app is listed in the search results as PowerShell (published by Microsoft Corporation). Click it to view its details, where you can also click Get to download and install it.
Install PowerShell Using Winget
The WinGet package manager installs the latest PowerShell version from the command line.
Search for PowerShell using Winget
To view a list of packages related to PowerShell, with their version numbers and IDs, use the following cmdlet:
winget search PowerShell
Install PowerShell
Locate the required PowerShell package and install it using its ID. The ID for PowerShell is Microsoft.PowerShell.
To install the latest PowerShell version, use the following cmdlet:
winget install Microsoft.PowerShell
Install PowerShell Using MSI Package
Another method is to download PowerShell from GitHub and use the MSI for installation. Visit the official PowerShell GitHub release page to locate the most recent PowerShell release (such as PowerShell 7.x). Scroll down to the Assets section of this release and download the MSI package.
The package takes some time to download. Once downloaded, run the installer to install PowerShell.
Managing Multiple PowerShell Versions
You can use the classic Windows PowerShell (usually version 5.1) and the modern PowerShell Core (versions 6.x and 7.x) on the same machine without conflicts.
A common use case for managing multiple PowerShell versions is when different environments or scripts require specific versions.
Here’s how you can manage multiple versions of PowerShell on your system.
Run a Specific Version from the Run dialog box or the Command Line
Open the Run dialog box and specify the path to the exe file of a PowerShell version to launch it (see the example below).
You can also run a specific PowerShell version by specifying its path in PowerShell, as provided in the following example. Note that this method is only valid for PowerShell 7, where you can switch between versions.
Example:
- PowerShell 5.1
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
- PowerShell 7
C:\Program Files\PowerShell\7\pwsh.exe
PowerShell Profiles and Configuration
A PowerShell profile is a PowerShell script that runs every time you launch PowerShell, except when you use the -NoProfile flag.
Each PowerShell version has its own profile file. If you want specific settings or configurations to be available in one version and not in the other, you have the option to configure the profile separately for each version.
Locate the profile file manually
- PowerShell 5.1 profile might be at: C:\Users\<username>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
- PowerShell 7+ profile might be at: C:\Users\<username>\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
Locate the profile file through PowerShell
You can also use PowerShell itself to retrieve the PowerShell profile. Simply use $Profile to locate the profile path, as the $Profile variable stores the path.
$Profile
This displays the path to the current user’s PowerShell host application profile. You can pipe the $Profile variable to the Get-Member cmdlet to get additional paths.
$Profile | Get-Member -MemberType NoteProperty
Test for Compatibility with Older Scripts and Modules
It is important to test for compatibility with older scripts and modules in PowerShell when upgrading to newer versions or integrating legacy code.
Following are some ways to test for compatibility with older scripts and modules.
Use Windows PowerShell and PowerShell Core Side by Side
You can run both Windows PowerShell and PowerShell Core on the same machine. Test your script or module in both environments for compatibility. Remember that 5.1 is the last major release of Windows PowerShell while version 7 is the current release of PowerShell Core.
An example is as:
./your_script.ps1
./ indicates that the script is located in the current directory while your_script.ps1 is the script you are trying to run. .ps1 is the default extension for PowerShell script files.
Check PowerShell Version
It is a good idea to know which version of PowerShell your script was initially written for, and which version you are trying to run it in.
Use the Test-ModuleManifest Cmdlet
The Test-ModuleManifest cmdlet is used to verify that a PowerShell module manifest (.psd1 file) is valid and correctly configured. It also checks the file for dependencies and compatibility issues.
Test-ModuleManifest -Path "C:\Path\To\YourModule.psd1"
The -Path parameter specifies the path to the .psd1 file.
Use the Get-Command Cmdlet to Check Cmdlet Availability
Some cmdlets and parameters may be supported in one PowerShell version and not in another. Use the Get-Command cmdlet to verify the availability and syntax of the cmdlets you are using. Here is an example:
Get-Command -Name Invoke-RestMethod -Module Microsoft.PowerShell.Utility
PSScriptAnalyzer for Static Code Analysis
PSScriptAnalyzer is a tool that checks for best practices and identifies compatibility issues. Use the following cmdlet to install and run it:
Install-Module -Name PSScriptAnalyzer Invoke-ScriptAnalyzer -Path "C:\Path\To\YourScript.ps1"
This is a good way to catch any issues with your scripts or deprecated cmdlets before runtime.
Check for .NET Compatibility
Windows PowerShell (5.1) is built on .NET Framework whereas PowerShell Core (6+) and PowerShell 7+ are built on .NET Core/.NET. In case your script or module relies on .NET assemblies, make sure they are compatible with both .NET Core/.NET and .NET Framework.
You can test the .NET assemblies used in your script with the following cmdlet:
[System.Reflection.Assembly]::LoadFile("C:\Path\To\YourAssembly.dll")
Conclusion
Knowing what version of PowerShell is installed on your computer is important for several reasons. Different versions come with new cmdlets, features, and syntax, so knowing the version ensures that your scripts are compatible with the version you are running them in. PowerShell Core introduced cross-platform compatibility, so knowing the installed version is key to using the right platform-specific features and modules.
Of all the methods available for determining the PowerShell version running on your computer, $PSVersionTable is highly recommended. It is not only the most reliable method, but also the most accurate for version identification. It provides a comprehensive overview of the PowerShell environment, helping you ensure that scripts are compatible with the specific version and environment.
You must regularly update PowerShell to ensure that critical security patches that protect against vulnerabilities found in earlier versions are installed. Moreover, regular update ensures access to the latest features, such as new cmdlets and cross-platform enhancements. It also guarantees improved performance, robust execution policies, and enhanced support for parallel and asynchronous execution. In short, upgrading to the latest PowerShell version helps create more secure, efficient, and scalable automation solutions, while reducing risks associated with outdated or unsupported versions.
FAQ
How to check powershell version?
The easiest way to check the PowerShell version is through PowerShell itself. You can show the PowerShell version you’re using, for example, via the PSVersionTable.PSVersion or the Get-Host cmdlet.