Mastering PowerShell: A Quick Guide to Checking Your Version in Windows 11
PowerShell stands as a cornerstone for system administration and task automation within the Windows ecosystem and beyond. Initially introduced by Microsoft as a command-line shell and scripting language, it has evolved significantly, offering powerful capabilities that extend far beyond the traditional Command Prompt. Understanding the version of PowerShell installed on your Windows system is crucial for compatibility, accessing the latest features, and ensuring you can leverage its full potential for managing everything from local systems to cloud services.
Every new iteration of PowerShell brings enhancements, new cmdlets (command-lets), performance improvements, and sometimes architectural shifts. While Windows traditionally ships with a specific version of Windows PowerShell, staying updated or knowing your current version is key, especially when troubleshooting scripts or trying out features demonstrated in online tutorials which might require a newer version.
Checking your PowerShell version is a straightforward process that can be accomplished with simple commands directly within the PowerShell interface. This guide will walk you through the primary methods to quickly ascertain which version you are running on Windows 11 or Windows 10.
Why Knowing Your PowerShell Version Matters¶
The landscape of PowerShell has changed over the years. We primarily distinguish between two main branches:
1. Windows PowerShell: This is the version that ships with Windows operating systems up to Windows 10 and Windows Server 2016/2019/2022. The latest version in this branch is 5.1. It is built on the .NET Framework.
2. PowerShell Core / PowerShell 7+: This is the cross-platform, open-source version built on .NET Core (now .NET). It was initially released as PowerShell Core and the latest major version is simply called PowerShell (e.g., PowerShell 7). This version is available on Windows, macOS, and Linux.
Knowing which version you are using is vital because:
* Feature Availability: Newer cmdlets and language features are introduced in later versions. A script written for PowerShell 7 might not run on Windows PowerShell 5.1 due to missing commands or syntax differences.
* Compatibility: Modules and snap-ins designed for specific versions might not work correctly or at all on others. Understanding your version helps you identify compatible tools.
* Performance and Reliability: Later versions often include performance optimizations and bug fixes that improve the overall scripting and command execution experience.
* Cross-Platform Capabilities: If you work in heterogeneous environments (Windows, Linux, Mac), knowing if you’re using the cross-platform PowerShell 7+ is fundamental.
For these reasons, being able to quickly check your installed PowerShell version is a fundamental skill for anyone working with the command line in Windows.
Method 1: Using the $PSVersionTable Automatic Variable¶
The most comprehensive and commonly used method to check your PowerShell version is by accessing the automatic variable $PSVersionTable. This variable is a hash table that provides detailed information about the PowerShell session and the host environment.
To use this method, follow these steps:
1. Open PowerShell. You can do this by typing “PowerShell” in the Windows search bar and clicking on the “Windows PowerShell” application or the “PowerShell” application (if you have PowerShell 7+ installed and configured in the start menu).
2. Once the PowerShell window is open, type the following command and press Enter:
$PSVersionTable
- The output will display a table with several entries, including
PSVersion,PSEdition,BuildVersion,CLRVersion(for Windows PowerShell),GitCommitId(for PowerShell 7+), and more.
Let’s look at an example output from Windows PowerShell 5.1:
Name Value
---- -----
PSVersion 5.1.22000.2593
PSEdition Desktop
InstallDate 02/04/2024 14:30:00
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0, 5.0, 5.1.22000.2593}
CLRVersion 4.0.30319.42000
BuildVersion 10.0.22000.2593
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationDataVersion 1.1.0.1
In this output, the PSVersion line clearly indicates the major, minor, and build number of the PowerShell version installed. The PSEdition line tells you whether it’s the Desktop edition (Windows PowerShell) or Core edition (PowerShell 7+).
And here’s an example output from PowerShell 7:
Name Value
---- -----
PSVersion 7.4.1
PSEdition Core
GitCommitId 7.4.1
OS Microsoft Windows 10.0.22000
Platform Win32NT
PlatformVersion 7.4.1
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0, 5.0, 5.1.10024.0, 6.0.0, 6.1.0, 6.2.0, 7.0.0, 7.1.0, 7.2.0, 7.3.0, 7.4.1}
PSRemotingProtocolVersion 2.3
SerializationDataVersion 1.1.0.1
WSManStackVersion 3.0
Notice the PSEdition: Core and the absence of CLRVersion, replaced by GitCommitId and OS/Platform information. This method provides the most detailed insight into your PowerShell environment.
Method 2: Using the Get-Host Cmdlet¶
Another reliable way to determine the PowerShell version is by using the Get-Host cmdlet. This cmdlet retrieves an object that represents the current host program for PowerShell. The object returned by Get-Host has a Version property that contains the version information.
To use Get-Host to check the version:
1. Open PowerShell as described in Method 1.
2. Type the following command and press Enter:
Get-Host
This will return information about the host application, including its name, version, and other properties. Look for the Version line in the output.
Example output from Windows PowerShell:
Name : ConsoleHost
Version : 5.1.22000.2593
InstanceId : <GUID>
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-US
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
The Version field here corresponds to the PSVersion seen in the $PSVersionTable output.
If you only want to see the version number and not the full host information, you can select just the Version property using Select-Object:
Get-Host | Select-Object Version
This command pipes the output of Get-Host to the Select-Object cmdlet, which then extracts only the Version property.
Example output using Select-Object:
Version
-------
5.1.22000.2593
This method provides a concise way to get just the version number.
Method 3: Accessing the Host Object’s Version Property Directly¶
Similar to Method 2, you can directly access the Version property of the current host object using the $host automatic variable. The $host variable holds the same host object returned by Get-Host.
To use this method:
1. Open PowerShell.
2. Type the following command and press Enter:
$host.version
This command directly accesses the version property of the object stored in the $host variable and displays its value.
Example output:
Major Minor Build Revision
----- ----- ----- --------
5 1 22000 2593
This output breaks down the version number into its constituent parts: Major, Minor, Build, and Revision. This is particularly useful if you only need one specific part of the version information for scripting purposes.
All three methods provide accurate information about the PowerShell version running on your system. $PSVersionTable offers the most detail, Get-Host | Select-Object Version provides a clean version string, and $host.version breaks down the version into its components.
Here is a visual representation of checking the PowerShell version:
Understanding PowerShell Versions: Windows PowerShell vs. PowerShell 7+¶
As mentioned earlier, it’s important to distinguish between Windows PowerShell (version 5.1 is the latest bundled with Windows) and PowerShell 7+ (the newer, cross-platform version).
Windows PowerShell 5.1:
* Default on Windows 10, Windows 11, Server 2016/2019/2022.
* Built on .NET Framework 4.x.
* Cmdlets are often specific to Windows management (e.g., managing IIS, Active Directory via specific modules).
* Generally receives updates via Windows Updates (though major version upgrades are tied to OS upgrades).
PowerShell 7+:
* Must be downloaded and installed separately.
* Built on .NET (formerly .NET Core).
* Cross-platform (Windows, macOS, Linux).
* Offers significant performance improvements.
* Introduces new operators (&&, ||, ?:, null-conditional operators ?., ?[]), ForEach-Object -Parallel, Switch with file support, and many new cmdlets and parameters.
* Can run side-by-side with Windows PowerShell 5.1.
* Updated more frequently and independently of the Windows operating system.
If you run $PSVersionTable and see PSEdition: Desktop, you are running Windows PowerShell. If you see PSEdition: Core, you are running PowerShell 7+. It is possible (and often recommended) to have both installed on the same machine. The executable for Windows PowerShell is typically powershell.exe, while for PowerShell 7+ it’s pwsh.exe.
How to Update or Install Newer PowerShell Versions¶
Keeping PowerShell updated, especially upgrading to PowerShell 7+, is highly recommended to benefit from new features, performance enhancements, and security fixes.
Updating Windows PowerShell (up to 5.1):
Windows PowerShell is primarily updated through Windows Updates. Ensuring your Windows operating system is fully updated is the main way to get the latest servicing releases for Windows PowerShell 5.1. Major version upgrades for Windows PowerShell were tied to new Windows versions (e.g., PowerShell 5.0 came with Windows 10 initial release, 5.1 with subsequent updates/Server 2016).
Installing or Updating PowerShell 7+:
PowerShell 7+ is installed independently of Windows and can be downloaded from the official Microsoft GitHub releases page or via winget (Windows Package Manager).
Steps to install PowerShell 7+ using winget:
1. Open the Windows Terminal (recommended) or Command Prompt as administrator.
2. Type the following command to install the latest stable version:
winget install Microsoft.PowerShell
3. Follow the prompts to complete the installation.
Alternatively, you can download the installer (.msi package) from the official PowerShell GitHub releases page. Find the latest stable release and download the x64 or x86 .msi file appropriate for your system architecture. Run the downloaded .msi file and follow the installation wizard.
Installing PowerShell 7+ will typically add a new entry to your Start Menu and make pwsh.exe available. You can then open the new version by searching for “PowerShell 7” or “pwsh”.
Let’s visualize the version check process with a simple flowchart:
mermaid
graph TD
A[Open PowerShell] --> B{Which Command?};
B --> C1[$PSVersionTable];
B --> C2[Get-Host];
B --> C3[$host.version];
C1 --> D1[Displays full details];
C2 --> D2[Displays host object details];
C3 --> D3[Displays version components];
D1 --> E[Identify PSVersion and PSEdition];
D2 --> F[Identify Version];
D3 --> G[Identify Major/Minor/Build/Revision];
E --> H[Understand your version and edition];
F --> H;
G --> H;
H --> I[Decide if upgrade is needed];
Using PowerShell within Windows Terminal¶
For a modern and enhanced command-line experience, Microsoft recommends using the Windows Terminal. Windows Terminal is a multi-tabbed terminal application that can host various command-line shells, including Command Prompt, PowerShell, WSL (Windows Subsystem for Linux) distributions, and Azure Cloud Shell.
When you install Windows Terminal, it often automatically detects your installed shells, including both Windows PowerShell and any installed versions of PowerShell 7+. You can open a new tab or pane within Windows Terminal and select which shell you want to use from a dropdown menu. This provides a much more user-friendly environment with features like tabs, panes, themes, and custom key bindings.
Right-clicking on the Desktop and selecting “Open in Windows Terminal” (or “Open in Windows Terminal as Admin”) is a common way to quickly launch a shell in a specific directory. Within Windows Terminal, you can run any of the version-checking commands discussed above in the PowerShell profile you have active.
Expanding PowerShell Capabilities¶
PowerShell’s utility extends to numerous system management tasks. Beyond the examples mentioned in the original article (listing services, disabled features, drivers, uptime, etc.), PowerShell can be used for:
- Active Directory Management: Cmdlets to create, modify, and delete users, groups, and organizational units.
- Exchange Server Management: Dedicated modules for managing mailboxes, transport rules, and server configurations.
- SQL Server Administration: Cmdlets to manage databases, instances, and run queries.
- Azure & Microsoft 365 Management: Extensive modules for interacting with cloud resources (virtual machines, storage, users, licenses).
- Software Deployment: Scripting software installations and configurations across multiple machines.
- Reporting and Auditing: Generating reports on system configurations, user activity, and security settings.
Understanding your PowerShell version is fundamental to effectively utilizing these capabilities, as the availability and functionality of specific cmdlets and modules can depend heavily on the version you are running.
For visual learners, searching for “PowerShell version check tutorial” or “Install PowerShell 7 Windows” on platforms like YouTube can provide helpful video guides demonstrating these steps. Many content creators offer detailed walkthroughs of PowerShell basics and advanced scripting techniques.
Troubleshooting Common Version Issues¶
While checking the version is simple, you might occasionally encounter issues:
- Command Not Found: If you type
$PSVersionTableand get an error, you might not be in a valid PowerShell session. Ensure you launched the correct “Windows PowerShell” or “PowerShell” application. - Unexpected Version: You might expect to see PowerShell 7 but only see Windows PowerShell 5.1. This means PowerShell 7 is likely not installed or not the default profile in your terminal. Verify installation or check your Windows Terminal settings.
- Confusing Output: The output of
$PSVersionTableorGet-Hostmight seem overwhelming initially. Focus on thePSVersionandPSEditionlines in$PSVersionTableor theVersionline fromGet-Hostfor the most critical information.
If you need a specific version for a script, make sure to launch that specific executable (powershell.exe for 5.1, pwsh.exe for 7+) or select the correct profile in Windows Terminal.
Conclusion¶
Checking your PowerShell version in Windows 11 or Windows 10 is a simple yet essential skill. Whether you use the detailed $PSVersionTable, the concise Get-Host | Select-Object Version, or the component-based $host.version, knowing your version is the first step towards effective scripting, compatibility management, and leveraging the powerful capabilities of this command-line environment. Staying informed about newer versions like PowerShell 7+ and understanding their advantages can significantly enhance your productivity and ability to manage modern IT environments.
We hope this detailed guide helps you master the process of checking your PowerShell version.
Do you use PowerShell frequently? Which version are you currently running, and what are your favorite cmdlets? Share your thoughts and experiences in the comments below!
Post a Comment