All Posts

How to Install PowerShell 7 Easy Installation Steps for Windows and Linux

How to Install PowerShell 7 Easy Installation Steps for Windows and Linux

The PowerShell team has just announced the release of PowerShell 7. Built on .NET Core 3, PowerShell 7 reintroduces many APIs needed by modules designed for .NET Framework, ensuring they work seamlessly with the .NET Core runtime. While PowerShell Core 6 aimed at cross-platform compatibility, PowerShell 7 focuses on becoming a viable replacement for Windows PowerShell 5.1 and achieving near parity with it. Here's a simple guide on how to install and update PowerShell 7 on both Windows and Linux using a one-liner.

For detailed insights into what's new in PowerShell 7, check out my blog post!

For a practical example of cross-platform PowerShell, visit my blog post on setting up PowerShell SSH Remoting.

Installing PowerShell 7

Before diving into the one-liner installation method, here's a brief overview of the official documentation for installing PowerShell 7 on various operating systems:

  • Installing PowerShell Core on Windows
  • Installing PowerShell Core on Linux
  • Installing PowerShell Core on macOS
  • Installing PowerShell Core on ARM

Install from the Microsoft Store

If you're using Windows 10, PowerShell 7 and higher versions can be easily installed via the Microsoft Store. You can search for it in the Microsoft Store app on Windows 10 or use this link.

Install PowerShell 7 using Winget

For Windows 10 users, the new command-line tool Winget simplifies the process of discovering, installing, upgrading, removing, and configuring applications. To get the latest version of PowerShell, type the following command:

shellCopy codewinget install PowerShell

Winget will also soon support automating the process of downloading apps from the Windows Store.

One-liner to Install or Update PowerShell 7 on Windows 10

Steve Lee, Microsoft Principal Software Engineer Manager in the PowerShell Team, shared a one-liner command to quickly install and update PowerShell 7:

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

Additional switches include:

  • -Destination: Specify the installation path.
  • -Daily: Install daily builds of the latest PowerShell previews.
  • -Preview: Install the latest preview version.
  • -UseMSI: Use the MSI installer.
  • -Quiet: Quiet installation mode.
  • -DoNotOverwrite: Prevent overwriting the destination folder if it exists.
  • -AddToPath: Add the installation path to the system PATH variable.

One-liner to Install or Update PowerShell 7 on Linux

For Linux users, you can use this one-liner to install PowerShell 7:

Depending on your distro, this command will register Microsoft package repositories and install the appropriate package (deb or rpm).

Additional switches include:

  • -includeide: Installs VSCode and VSCode PowerShell extension.
  • -interactivetesting: Launch VSCode for a quick test.
  • -skip-sudo-check: Use sudo without verifying its availability.
  • -preview: Install the latest preview release alongside any existing production releases.

To run the PowerShell Preview, use:

shellCopy codepwsh

After Installing

After installing PowerShell 7, remember to update PowerShellGet and the PackageManagement module.

On Windows 10, I prefer using the Microsoft Store for installation, complemented by Winget for command-line operations. I hope this guide was helpful. If you have any questions, please leave a comment!

Comments (0)

Leave a Comment

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