How to Do a PowerShell Version Check

How to Do a PowerShell Version Check blog banner image

In this article, you will learn how to do a PowerShell version check. Understanding which PowerShell you have installed is necessary to make sure it’s compatible with scripts, modules and features. PowerShell has evolved significantly over the years, transitioning from a Windows-only tool to an open-source, cross-platform framework known as PowerShell Core.

Introduction to PowerShell versioning

PowerShell, developed by Microsoft, was first introduced in 2006 as a task automation framework primarily for Windows systems. Over the years, it has evolved significantly, leading to various versions of PowerShell, each with its own set of features, improvements, and compatibility considerations.

The original PowerShell, now often referred to as Windows PowerShell, was closely tied to the Windows operating system and included in most Windows installations. However, as the need for cross-platform compatibility grew, Microsoft introduced and expanded upon their PowerShell versions until the latest, PowerShell Core, an open-source, cross-platform tool.

Learn everything you need to know about PowerShell with this NinjaOne crash course. → Sign up today.

Why it’s important to know your PowerShell version

Knowing your PowerShell version is not just about staying current; it’s about making certain that your scripts and modules function as expected. Different PowerShell versions come with varying sets of cmdlets, features, and compatibility with external modules. Here are some reasons you should be aware of your PowerShell versions:

  • Compatibility: Different PowerShell versions support different cmdlets, features, and external modules. A script written for PowerShell 7.x may not run on Windows PowerShell 5.1 due to differences in available cmdlets or syntax changes. Conversely, older scripts may fail on newer versions if they rely on deprecated features.
  • Performance and features: Running older versions of PowerShell may mean missing out on significant performance improvements, security updates, and new functionalities introduced in later versions. These updates often include bug fixes and enhancements that make automation tasks more efficient and secure.
  • Security: Microsoft regularly releases updates to address vulnerabilities and improve overall platform security. Using an outdated version of PowerShell can expose your systems to security risks, particularly if those versions are no longer supported with patches or updates.
  • Troubleshooting: Understanding your PowerShell version is essential when troubleshooting issues. Knowing which version you are using can help you quickly identify if the problem is related to version compatibility, missing features, or deprecated functionality, allowing you to take appropriate action.

How to perform a PowerShell version check

Knowing your PowerShell version is straightforward and there are several methods you can use to determine it. Below, we’ll explore different techniques depending on your operating system and preferences.

Using the $PSVersionTable command

The most common and straightforward way to perform a PowerShell version check is by using the $PSVersionTable command. This command returns a table of information about your PowerShell environment, including the version number.

To perform a version check:

  1. Open PowerShell.
  2. Type “$PSVersionTable” and press “Enter.”
  3. Look for the PSVersion entry in the output. This value indicates the version of PowerShell installed on your system.

For example, if the PSVersion shows 5.1.19041.1023, you are running Windows PowerShell 5.1. The $PSVersionTable output also includes other valuable details, such as the CLR version (for Windows PowerShell) or the PSEdition, which distinguishes between Windows PowerShell and PowerShell Core.

This method is universally applicable across all platforms where PowerShell is installed, making it the go-to command for a quick PowerShell version check.

PowerShell version check via the registry

Another method to check your PowerShell version, particularly on Windows systems, is by examining the Windows Registry. This approach can be useful if you need to verify the version of PowerShell installed without opening the PowerShell console.

To check via the registry:

  1. Press Win + R on your keyboard, type “regedit” and press “Enter” to open the Registry Editor.
  2. Navigate to HKEY_LOCAL_MACHINESOFTWAREMicrosoftPowerShell3PowerShellEngine.
  3. Look for the PowerShellVersion entry. The value here represents the installed version of PowerShell.

This way is more technical and is typically used in scenarios where you need to programmatically perform a PowerShell version check or when working in environments where accessing the PowerShell console is restricted.

Identifying version differences on Windows vs. Mac/Linux

PowerShell version checks on macOS or Linux is similar to the process on Windows, but there are a few key differences to be aware of. On non-Windows systems, PowerShell is usually installed as PowerShell Core and the version can be checked using the same $PSVersionTable command in a terminal.

On these platforms, it’s important to note that PowerShell Core and PowerShell 7.x are the only versions available, as Windows PowerShell (versions 5.1 and earlier) is exclusive to Windows. When you run $PSVersionTable, you should see the PSEdition listed as Core, which distinguishes it from Windows PowerShell.

In addition to using the $PSVersionTable command, you can also check the version by typing “pwsh –version” in the terminal. This command directly outputs the version number of PowerShell Core installed on your system.

Common PowerShell versions and their features

PowerShell has undergone several major updates since its initial release, each bringing new features and enhancements. Below are the most common versions you might encounter and the features they offer.

Windows PowerShell 5.1:

  • Compatibility: The last version of Windows PowerShell, version 5.1, is widely used in enterprise environments due to its integration with Windows. It supports a vast array of cmdlets and is compatible with many legacy scripts and modules.
  • Security Enhancements: This version introduced improvements in script block logging and constrained language mode, enhancing security for administrators.
  • Desired State Configuration (DSC): PowerShell 5.1 includes significant improvements to DSC, allowing for better configuration management across multiple machines.

PowerShell 6.0 (PowerShell Core):

  • Cross-Platform: Marking a significant shift, PowerShell Core is the first version to support cross-platform usage, running on Windows, macOS and Linux.
  • Performance: PowerShell Core 6.0 offers performance improvements over its predecessor, making it faster and more efficient.
  • Open Source: PowerShell Core is open-source, allowing the community to contribute to its development and ensuring more frequent updates and improvements.

PowerShell 7.x:

  • Unified Experience: PowerShell 7.x combines the best features of Windows PowerShell and PowerShell Core, offering a unified scripting environment that is both powerful and versatile.
  • Pipeline Parallelization: Introduced in PowerShell 7.0, this feature allows for faster processing of data by running pipeline commands in parallel.
  • Enhanced Error Handling: PowerShell 7.x includes new error handling features, such as -ErrorAction and -ErrorVariable, providing more control over how scripts handle exceptions.

Power up your IT operations with NinjaOne’s 30-minute crash course on PowerShell basics. → Learn how here.

How to Update PowerShell to the Latest Version

Keeping your PowerShell installation up-to-date is considered a best practice for security, compatibility and accessing the latest features. Below are steps for updating PowerShell on different platforms.

Updating on Windows

  1. Visit the PowerShell GitHub page to download the latest version of PowerShell.
  2. Download the installer for your system architecture (x64 or x86).
  3. Run the installer and follow the prompts to complete the installation.
  4. After installation, open a new PowerShell window and use the $PSVersionTable command to verify the update.

Updating on macOS

  1. Open a terminal window.
  2. If PowerShell was installed using Homebrew, first run brew update to refresh Homebrew’s package database.
  3. Next, execute brew upgrade powershell to install the latest version of PowerShell.
  4. Verify the update by typing “pwsh –version” in the terminal. This will display the current version of PowerShell installed on your system.

Updating on Linux:

  1. Open a terminal window.
  2. For Debian-based systems like Ubuntu:
    1. Run sudo apt-get update to update your package lists.
    2. Then, execute sudo apt-get install -y powershell to install the latest version.
  3. For Red Hat-based systems like CentOS:
    1. Run sudo yum update powershell.
    2. Follow up with sudo yum install -y powershell.
  4. Confirm the update by typing “pwsh –version” in the terminal, which will display the current PowerShell version installed.

By regularly checking and updating your PowerShell installation, you can validate that you’re taking full advantage of the latest improvements while maintaining a secure and efficient IT environment. The version you use can significantly impact the features available to you, the security of your environment and the compatibility of your scripts.

NinjaOne can help IT administrators streamline their operations by automating repetitive tasks, such as PowerShell scripting, ensuring that networks function optimally and data remains secure. Discover how NinjaOne’s IT automation tools can save you time and enhance efficiency in your daily tasks. Try NinjaOne now for free.

Next Steps

For MSPs, their choice of RMM is critical to their business success. The core promise of an RMM is to deliver automation, efficiency, and scale so the MSP can grow profitably. NinjaOne has been rated the #1 RMM for 3+ years in a row because of our ability to deliver an a fast, easy-to-use, and powerful platform for MSPs of all sizes.
Learn more about NinjaOne, check out a live tour, or start your free trial of the NinjaOne platform.

You might also like

Ready to become an IT Ninja?

Learn how NinjaOne can help you simplify IT operations.

×

See NinjaOne in action!

By submitting this form, I accept NinjaOne's privacy policy.

NinjaOne Terms & Conditions

By clicking the “I Accept” button below, you indicate your acceptance of the following legal terms as well as our Terms of Use:

  • Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms.
  • Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party.
  • Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library belonging to or under the control of any other software provider.
  • Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations.
  • Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks.
  • Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script.
  • EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).