How to upgrade PowerShell version
Categories:
How to Upgrade PowerShell to the Latest Version
Learn how to seamlessly upgrade PowerShell on Windows, from older versions like 5.1 to the modern PowerShell 7.x, ensuring you have the latest features and performance enhancements.
PowerShell is a powerful, cross-platform task automation and configuration management framework. While Windows operating systems typically ship with Windows PowerShell 5.1, many modern features, performance improvements, and cross-platform capabilities are only available in PowerShell 7.x (often referred to as PowerShell Core). This article will guide you through the process of upgrading your PowerShell installation to the latest stable version, ensuring you can leverage all its new capabilities.
Understanding PowerShell Versions: Windows PowerShell vs. PowerShell 7.x
Before diving into the upgrade process, it's crucial to understand the distinction between Windows PowerShell and PowerShell 7.x. Windows PowerShell (versions 1.0 through 5.1) is built on the .NET Framework and is an integral part of Windows operating systems. PowerShell 7.x, on the other hand, is built on .NET Core (now .NET) and is cross-platform, meaning it runs on Windows, macOS, and Linux. PowerShell 7.x installs side-by-side with Windows PowerShell 5.1, allowing you to have both versions on your system simultaneously. This means upgrading to PowerShell 7.x won't replace your existing Windows PowerShell installation, but rather provide a new, more powerful environment.
Comparison of Windows PowerShell 5.1 and PowerShell 7.x
Methods for Upgrading PowerShell
There are several reliable methods to upgrade PowerShell on Windows. The most common and recommended approaches involve using the MSI package, Winget, or the .NET Global Tool. Each method has its advantages depending on your environment and preferences. For most users, the MSI package provides the simplest graphical installation experience, while Winget offers a command-line driven approach that can be easily automated. The .NET Global Tool is ideal for developers who already have the .NET SDK installed.
1. Step 1
Open your preferred web browser and navigate to the official PowerShell GitHub releases page: https://github.com/PowerShell/PowerShell/releases
.
2. Step 2
On the releases page, locate the latest stable release. Look for the section titled 'Assets' under the release notes.
3. Step 3
Download the appropriate MSI package for your Windows architecture. For most modern systems, this will be PowerShell-7.x.x-win-x64.msi
(where 7.x.x
is the version number).
4. Step 4
Once the download is complete, run the MSI installer. Follow the on-screen prompts, accepting the default options or customizing them as needed (e.g., installation path).
5. Step 5
After the installation finishes, open the new PowerShell 7 terminal (it will typically be named 'PowerShell 7' in your Start Menu) and verify the version by typing $PSVersionTable.PSVersion
.
$PSVersionTable.PSVersion
Upgrading using Winget (Windows Package Manager)
Winget is Microsoft's official package manager for Windows, providing a convenient command-line interface to install and manage applications. If you have Winget installed (it's included by default in Windows 10 1709+ and Windows 11), you can use it to upgrade PowerShell with a single command.
1. Step 1
Open an elevated Command Prompt or Windows PowerShell 5.1 terminal (Run as Administrator).
2. Step 2
First, check if PowerShell is already installed via Winget by running: winget search Microsoft.PowerShell
.
3. Step 3
If PowerShell is found, upgrade it using the command: winget upgrade --id Microsoft.PowerShell --source winget
.
4. Step 4
If PowerShell is not found or you want to ensure a fresh installation, you can install it directly: winget install --id Microsoft.PowerShell --source winget
.
5. Step 5
After the command completes, close and reopen your terminal or open a new PowerShell 7 terminal to verify the installation.
# Search for PowerShell (optional)
winget search Microsoft.PowerShell
# Upgrade PowerShell
winget upgrade --id Microsoft.PowerShell --source winget
# Or install if not present
# winget install --id Microsoft.PowerShell --source winget
Upgrading using .NET Global Tool (Advanced)
If you are a developer and already have the .NET SDK installed on your system, you can install or update PowerShell as a .NET Global Tool. This method is particularly useful for managing PowerShell versions alongside other .NET tools.
1. Step 1
Ensure you have the .NET SDK installed. You can check this by running dotnet --list-sdks
in your terminal.
2. Step 2
To install PowerShell as a global tool, use the command: dotnet tool install --global PowerShell
.
3. Step 3
If PowerShell is already installed as a global tool, update it with: dotnet tool update --global PowerShell
.
4. Step 4
After installation/update, you can run PowerShell 7 directly from any terminal using the pwsh
command. Verify the version with $PSVersionTable.PSVersion
.
# Check .NET SDKs
dotnet --list-sdks
# Install PowerShell as a global tool
dotnet tool install --global PowerShell
# Update PowerShell if already installed
dotnet tool update --global PowerShell
By following these methods, you can successfully upgrade your PowerShell environment to the latest version, unlocking a wealth of new features, improved performance, and cross-platform compatibility. Remember to always test your existing scripts in the new environment after an upgrade to ensure full compatibility.