How to Install and Update PowerShell 7
Currently, you can install the cross-platform version PowerShell Core 6 on Linux, macOS, and Windows. Early April the PowerShell team announced the next release called 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 (preview) on Windows and Linux using a simple one-liner.
If you want to know more about the roadmap, check out Steves 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 (Preview)
As mentioned PowerShell 7 is currently in preview. You can download and install it manually from GitHub. However, the easiest way to install it is to use the following one-liners created by Steve Lee (Microsoft Principal Software Engineer Manager in the PowerShell Team). You can also use the same one-liners with different parameters to install the current GA version of PowerShell 6.
If you are installing the PowerShell 7 Preview, this will be a side by side installation with PowerShell 6. You can use the pwsh-preview command to run version 7.
One-liner to install or update PowerShell 7 on Windows 10
You can use this single command in Windows PowerShell to install PowerShell 7. The difference between the installation of version 6 versus version 7 is the -Preview flag.
iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI -Preview"
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. This will
-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 -preview; 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-preview
After Installing
After you have installed PowerShell 7, also make sure to update PowerShellGet and the PackageManagement module.
Remember PowerShell 7 is still currently in preview, if you have any questions, please let me know in the comments.
You can also use my PSReleaseTools module (https://github.com/jdhitsolutions/PSReleaseTools) which is in the PowerShell Gallery. It works cross platform and you can easily download setup files. Here’s how you could download and install the 64bit msi for Windows 10:
Get-PSReleaseAsset -Preview -Family Windows -Only64Bit | where format -eq ‘msi’ | Save-PSReleaseAsset -Path d:\ -Passthru | Invoke-Item
Hi Thomas,
How do I update or install PowerShelll 7 in disconnected environment ? These are machines with no outside connectivity.
Thanks,
Hi, In that case, you just download the MSI installer from GitHub and copy it to the machine :)
https://github.com/powershell/powershell You have a download table, make sure you for PowerShell 7, that you download the preview version.
Was so happy I can finally install the MSOnline module but Powershell 7 can’t get seem to get passed a “Could not load type ‘System.Security.Cryptography.SHA256Cng” error when I try to Connect-MSOnlineService . Hopefully they can get passed it by the time it becomes GA.
If you are on a Linux system that supports snaps you can install both the current and preview versions of Powershell from the Snap store.
e.g. for Powershell 6 – sudo snap install powershell –classic
and for Powershell 7 – sudo snap install powershell-preview –classic
Note that these snaps are published by Microsoft. Also the –classic flag is required as the snaps are published with classic confinement.
Is powershell 7 currently available for MAC Sierra edition? Thank you