Written by 8:39 am Microsoft, PowerShell, Windows, Windows Server • 49 Comments

How to Install and Update PowerShell 7

PowerShell 7 Installer

The PowerShell team just announced PowerShell 7. PowerShell 7 is built on .NET Core 3 and brings back many APIs required by modules built on .NET Framework so that they work with .NET Core runtime. While PowerShell Core 6 was focusing on bringing cross-platform compatibility, PowerShell 7 will focus on making it a viable replacement for Windows PowerShell 5.1 and bringing near parity with Windows PowerShell. Here is how you can install and update PowerShell 7 on Windows and Linux using a simple one-liner.

If you want to know what’s new in PowerShell 7, check out my blog post!

One great example of how cross-platform PowerShell can work, check out my blog post: How to set up PowerShell SSH Remoting.

Install PowerShell 7

Before showing you the one-liner option to install PowerShell 7, I want to share with you the documentation to install PowerShell 7 on different operating systems like Windows, macOS, and Linux.

Install from the Microsoft Store

If you are running Windows 10, you can easily install PowerShell 7 and higher through the Microsoft Store.

Download and install PowerShell in the Microsoft Store
Download and install PowerShell in the Microsoft Store

You can search it in the Microsoft Store app on Windows 10 or you can simply use this link.

Install PowerShell 7 using winget

If you are running Windows 10, and you have a new command-line tool called winget. The winget command line tool enables you to easily discover, install, upgrade, remove and configure applications on Windows 10 computers.

PowerShell Winget
PowerShell Winget

You can simply type the following command, to get the latest version of PowerShell.

winget install PowerShell

Later you will also be able to automate the process to download apps from the Windows Store using Winget.

One-liner to install or update PowerShell 7 on Windows 10

Steve Lee (Microsoft Principal Software Engineer Manager in the PowerShell Team) shared some one-liner, which helps you quickly install and update:

You can use this single command in Windows PowerShell to install PowerShell 7.

iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"

There are additional switches to, for example, install daily builds of the latest PowerShell previews.

-Destination
The destination path to install PowerShell Core to.

-Daily
Install PowerShell Core from the daily build.
Note that the ‘PackageManagement’ module is required to install a daily package.

-Preview
Install the latest preview, which is currently version 7.

-UseMSI
Use the MSI installer.

-Quiet
The quiet command for the MSI installer.

-DoNotOverwrite
Do not overwrite the destination folder if it already exists.

-AddToPath
On Windows, add the absolute destination path to the ‘User’ scope environment variable ‘Path’;
On Linux, make the symlink ‘/usr/bin/pwsh’ points to “$Destination/pwsh”;
On MacOS, make the symlink ‘/usr/local/bin/pwsh’ points to “$Destination/pwsh”.

One-liner to install or update PowerShell 7 on Linux

You can use this as a single command to install PowerShell 7 on Linux.

wget https://aka.ms/install-powershell.sh; sudo bash install-powershell.sh; rm install-powershell.sh

Depending on your distro you are using, this will register Microsoft’s pkg repos and install that package (deb or rpm).

You can also use the following switches:

-includeide
Installs VSCode and VSCode PowerShell extension (only relevant to machines with a desktop environment)

-interactivetesting
Do a quick launch test of VSCode (only applicable when used with -includeide)

-skip-sudo-check
Use sudo without verifying its availability (hard to accurately do on some distros)

-preview
Installs the latest preview release of PowerShell side-by-side with any existing production releases

To currently run the PowerShell Preview, you can run the following command:

pwsh

After Installing

After you have installed PowerShell 7, also make sure to update PowerShellGet and the PackageManagement module.

You might ask, what my preferred way is? On Windows 10 I am definitely using the Microsoft Store and with winget I can easily do that from the command line. I hope this blog post was helpful. If you have any questions, please let me know in the comments.

Tags: , , , , , , , , , , , , , , , , , Last modified: July 16, 2021
Close Search Window
Close