How to Update PowerShell – Quick Guide!

PowerShell 7 is undoubtedly the most significant release of PowerShell since its inception. This new version has significant improvements over its predecessor, PowerShell 5.1, and it’s faster, more powerful, and more flexible. While it is still relatively new, many users are switching to PowerShell 7. If you’re yet to upgrade to PowerShell 7, it’s time to make the move! To take full advantage of its capabilities and ensure access to the latest features and cmdlets in scripts, it’s important to keep PowerShell updated. In this comprehensive guide, we’ll cover various methods to update PowerShell to the latest version and how to install or upgrade to PowerShell 7. Let’s get started!

Understanding the Different Versions of PowerShell

Before we dive into updating PowerShell, it’s important to understand that there are two distinct versions of PowerShell:

  1. Windows PowerShell: This is the classic version of PowerShell, with the latest and final version being 5.1. Windows PowerShell is no longer being actively updated, as Microsoft has shifted its focus to PowerShell Core.
  2. PowerShell Core: This is the new, open-source, cross-platform version of PowerShell, with the current version being 7.3. PowerShell Core is built on .NET Core and is designed to be compatible with most Windows PowerShell scripts and cmdlets.

While the version numbering for PowerShell Core continues from 5.1 (6.0, 6.1, 7.0, 7.1, etc.), the two platforms are distinct and require separate update processes.

Checking Your Current PowerShell Version

Before updating PowerShell, it’s essential to determine which version you currently have installed. To do this, follow these simple steps:

  1. Open Windows PowerShell.
  2. Type the following command and press Enter:

This command will display your current PowerShell version in the console. 

Get PowerShell Version

Updating from PowerShell 3, 4 to PowerShell 5.1

PowerShell 5.1 is installed on Windows systems by default and is part of the Windows Management Framework 5.1 (which requires the .NET Framework 4.5.2 or later). It automatically updates with Microsoft Update, so ensure your system is up to date to have the latest version of PowerShell 5.1. If you are using an older version of PowerShell (such as PowerShell 3 or 4 on Windows Server 2012 R2, 2012, 2008 R2 SP1, Windows 8.1, and Windows 7 SP1), you can update to PowerShell 5.1 by installing the Windows Management Framework 5.1

Introduction to PowerShell 7

PowerShell 7, also known as PowerShell Core 7, is the latest version of PowerShell and can be installed alongside PowerShell 5.1. With the release of PowerShell 7, Microsoft has introduced a wealth of new features, performance improvements, and bug fixes, making it a must-have update for IT professionals, developers, and automation enthusiasts.

In this comprehensive guide, we will explore the benefits of updating to PowerShell 7, the key differences between PowerShell 7 and previous versions, the prerequisites for upgrading, and detailed step-by-step instructions on how to update PowerShell on various platforms. We will also delve into the new features and improvements introduced in PowerShell 7, and provide resources to help you master this powerful tool.

Let’s begin our journey toward mastering PowerShell 7!

Why should we update to PowerShell 7?

There are numerous reasons to consider updating to PowerShell 7, as it offers significant enhancements to its predecessors. Here are some compelling reasons to upgrade:

  1. Cross-platform compatibility: PowerShell 7 is built on .NET Core, which allows it to run on Windows, macOS, and Linux. This enables you to use the same PowerShell scripts and modules across different operating systems, streamlining your workflows and making your automation efforts more efficient.
  2. Improved performance: PowerShell 7 boasts enhanced performance, thanks to the underlying .NET Core runtime. This means faster script execution, reduced memory usage, and better overall performance, allowing you to accomplish your tasks more efficiently.
  3. New features and improvements: PowerShell 7 introduces a wealth of new features, cmdlets, and improvements, such as enhanced PowerShell remoting, improved error messages, and support for ternary operators. These enhancements make PowerShell 7 more powerful, versatile, and user-friendly.
  4. Long-term support: PowerShell 7 is a long-term support (LTS) release, meaning it will receive updates and bug fixes for an extended period. This ensures that your PowerShell environment remains stable, secure, and up-to-date.
  5. Compatibility with Windows PowerShell: PowerShell 7 offers a high level of compatibility with Windows PowerShell, allowing you to continue using your existing scripts and modules with minimal modifications. This makes the transition to PowerShell 7 smoother and less disruptive.
  6. Enhanced security: PowerShell 7 includes several security improvements, such as the new -NoLogo switch, which prevents the display of potentially sensitive information in the PowerShell console, and improved logging capabilities, which help you monitor and audit your PowerShell activities.
  7. Pipeline parallelization: PowerShell 7 introduces the ForEach-Object -Parallel cmdlet, which enables parallel execution of script blocks across multiple cores and threads. This can significantly improve the performance of scripts that process large amounts of data.
  8. Additional cmdlets and modules: PowerShell 7 includes several new cmdlets and modules, such as the ConvertFrom-Json and ConvertTo-Json cmdlets for working with JSON data, and the Microsoft.PowerShell.GraphicalTools module for building graphical user interfaces (GUIs). PowerShell 7 includes improved error messages.

Prerequisites for upgrading to PowerShell 7

Before upgrading to PowerShell 7, you should ensure that your system meets the following requirements:

  1. Supported operating systems: Ensure that you are running a compatible operating system. PowerShell 7 supports Windows 7, 8.1, 10, and 11; macOS 10.13 and later; and various Linux distributions, including Ubuntu, Debian, CentOS, Fedora, and more.
  2. .NET Core 3.1: PowerShell 7 requires .NET Core 3.1 to be installed on your system. You can download the latest version of .NET Core from the Official website.
  3. Backup your existing PowerShell configuration: Before upgrading, it is recommended to back up your existing PowerShell configuration, including profiles, scripts, and modules, to ensure a smooth transition and minimize the risk of data loss.

Step-by-step guide: How to update PowerShell on Windows 10/11?

There are several methods to install or update PowerShell Core 7 on your Windows system:

Method 1: Using Winget Command

Winget is a command-line package manager introduced in Windows 10, which allows you to download and install software packages from a centralized repository. To install or update PowerShell Core 7 using Winget command-line tool, follow these steps:

  1. Open a PowerShell terminal window with administrative privileges.
  2. To search for the available PowerShell versions, run the following command:
winget search Microsoft.Powershell
  1. To install the desired PowerShell Core version, use the following command:
winget install --id Microsoft.PowerShell

This will download and install the latest stable PowerShell Core release. Similarly, If you want to update your existing PowerShell 7 version to the latest build, You use:

winget upgrade --id Microsoft.PowerShell
update powershell 7

Method 2: Using GitHub to Download PowerShell 7 Installer

PowerShell Core can be installed or updated by downloading the installer package from the GitHub website. Follow these steps to download and install PowerShell Core from GitHub:

  1. Visit the GitHub PowerShell page and select the latest release version.
    Download PowerShell from GitHub
  2. Scroll to the Assets section and download the appropriate MSI package or zip package for your operating system.
  3. Run the installer package and follow the installation wizard to complete the process. During installation, you can enable WSUS or Windows update to update PowerShell.
    Install PowerShell 7

How to Update PowerShell 7 to the Latest Build?

If you have installed PowerShell 7 with an MSI, You can upgrade to the latest build by downloading and installing the latest MSI from the GitHub PowerShell page to update PowerShell 7.

Method 3: Using Microsoft Store

PowerShell Core can be installed or updated through the Microsoft Store on Windows 10 and Windows 11 systems. To install or update PowerShell Core using the Microsoft Store, follow these steps:

  1. Open the Microsoft Store app on your PC.
  2. Search for the “PowerShell” app.
    Install PowerShell 7 from Microsoft Store
  3. Click the Get or Update button to download and install the app on your system.

Launch PowerShell 7

After the installation, To access PowerShell 7, open the Start Menu, search for “PowerShell 7,” and select the PowerShell 7 option.

Access PowerShell 7

Please note that you can’t use PowerShell ISE with PowerShell 7 yet! So, use Visual Studio Code.

Verify the PowerShell 7 Version:

Open a new PowerShell console and type Get-Host. The “Version” property should display “7.x.x” (where “x” represents the version number). Ensure your existing scripts and modules work correctly in PowerShell 7. If you encounter any issues, refer to the PowerShell 7 migration guide for assistance.

Upgrading PowerShell on other platforms (Mac, Linux)

PowerShell 7 can also be installed on macOS and Linux. The installation process for these platforms is similar to Windows, with some platform-specific differences:

  1. macOS: Download the PowerShell 7 PKG installer from the PowerShell GitHub repository and run it. Follow the on-screen prompts to complete the installation. Verify the installation by opening a new terminal and typing pwsh.
  2. Linux: Installation on Linux varies depending on your distribution. Follow the official documentation for detailed instructions on installing PowerShell 7 on your specific Linux distribution.

Common issues and troubleshooting during the upgrade process

While upgrading to PowerShell 7 is generally a straightforward process, there are some common issues that users may encounter. Here are some tips for troubleshooting common issues:

  1. Installation errors: If you encounter errors during the installation process, ensure that you have met all the prerequisites, such as installing .NET Core 3.1, and that you are using the correct installer for your system.
  2. Compatibility issues: If your existing scripts and modules do not work correctly in PowerShell 7, refer to the PowerShell 7 migration guide for guidance on updating your code.
  3. Performance issues: If you experience performance issues, such as slow script execution or high memory usage, ensure you are using the latest version of PowerShell 7 and .NET Core, and consider optimizing your scripts for parallel execution.
  4. Security issues: If you encounter security issues, such as unauthorized access or data breaches, review your PowerShell security settings and ensure that you are following best practices for secure scripting.

Conclusion and next steps in your PowerShell journey

Updating to the new version of PowerShell is essential to ensure access to the latest features and improve script compatibility. While PowerShell 5.1 is still commonly used, PowerShell 7 offers advanced capabilities and cross-platform support. By following the methods outlined in this article, you can quickly install or update Windows PowerShell 5.1 and PowerShell Core 7 to the latest versions and enhance your scripting experience. We have explored the benefits of updating to PowerShell 7, the prerequisites for upgrading, and detailed step-by-step instructions on how to update PowerShell on various platforms. By upgrading to PowerShell 7, you can take advantage of its cross-platform capabilities, improved performance, and new features and improvements.

Should I use Windows PowerShell 5.1 or PowerShell Core 7?

While Windows PowerShell 5.1 is still installed by default on Windows client and server operating systems, Microsoft recommends using PowerShell Core 7 when possible, as it is the platform that will receive ongoing development and updates. However, testing your existing scripts and modules for compatibility with PowerShell Core 7 before fully transitioning is important.

How do I check the version of PowerShell Core 7 after installation?

After installing PowerShell Core 7, you can check the version by opening a PowerShell Core window and running the $PSVersionTable.PSVersion command.

Can I have both Windows PowerShell and PowerShell Core 7 installed on the same system?

Yes, PowerShell Core 7 is installed alongside Windows PowerShell, allowing you to use both versions on your system. This lets you gradually transition to PowerShell Core 7 while maintaining access to Windows PowerShell for compatibility purposes.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

Leave a Reply

Your email address will not be published. Required fields are marked *