Today Windows 10 and Windows Server 2019 ship with Windows PowerShell 5.1 as the default version. PowerShell Core 6 is a new edition of PowerShell that is cross-platform (Windows, macOS, and Linux), open-source, and built for heterogeneous environments and the hybrid cloud. PowerShell 6 today is a side by side version next to Windows PowerShell 5.1. That means on Windows you cannot just upgrade to PowerShell 6, you will need to install it, same as on Linux and macOS. This blog post shows you how simple you can install PowerShell 6 or update PowerShell 6, if you have already installed it, on Windows 10, Windows Server 2019 or Linux.
One great example of how cross-platform PowerShell can work, check out my blog post: How to set up PowerShell SSH Remoting
Of course, you can find excellent documentation out there on Microsoft Docs. However, Steve Lee (Microsoft Principal Software Engineer Manager in the PowerShell Team) shared some one-liner, which helps you quickly install and update PowerShell 6.
Install #PScore6 on Windows using a single command line from Windows PowerShell: iex “& { $(irm https://t.co/oXHZpO8yPJ) } -UseMSI -Preview”
You can look at the script to see what switches are available, this will use the MSI to install latest Preview.
— Steve Lee (@Steve_MSFT) February 1, 2019
Install PowerShell Core 6
Before showing you the one-liner option to install PowerShell 6, I want to share with you the documentation to install PowerShell Core 6 on different operating systems like Windows, macOS, and Linux.
- Installing PowerShell Core on Windows
- Installing PowerShell Core on Linux
- Installing PowerShell Core on macOS
- Installing PowerShell Core on ARM
One-liner to install or update PowerShell 6 on Windows 10
Update: Since PowerShell 7 was just released, this one-liner will now install PowerShell 7.
If you want to know more about what is new in PowerShell 7, check out my blog post.
You can use this single command in Windows PowerShell to install PowerShell 7. (Update: Since PowerShell 7 was just released, this one-liner will now install PowerShell 7.)
iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"
There are additional parameters 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.
-UseMSI
Use MSI installer.
-Quiet
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”.
For more about installing PowerShell 6 on Windows, check out the Microsoft Docs.
One-liner to install or update PowerShell 6 on Linux
You can use this as a single command to install PowerShell 7 on Linux (Update: Since PowerShell 7 was just released, this one-liner will now install PowerShell 7.)
wget -O - https://aka.ms/install-powershell.sh | sudo bash
Depending on your distro you are using, this will register Microsoft’s pkg repos and install that package (deb or rpm).
For more about installing PowerShell 6 on Linux, or if you want to install PowerShell Core 6 on macOS, check out the Microsoft Docs.
After Installing
After you have installed PowerShell 6, also make sure to update PowerShellGet and the PackageManagement module. If you are looking about how to install and update PowerShell 7, check out my blog post.
By the way, PowerShell 6 is also used in the PowerShell version of Azure Cloud Shell. You can of course also install the Azure PowerShell module in PowerShell 6.
Tags: install, Linux, macOS, Microsoft, PowerShell, PowerShell 6, PowerShell Core, PowerShell Core 6, update, Windows, Windows 10, Windows Powershell, Windows Server Last modified: March 4, 2020
[…] ihr die Windows PowerShell unter Linux oder macOS installieren, so findet ihr auf dem Blog von Thomas Mauerer sehr ausführliche Informationen dazu. Weiterhin beschreibt er auch noch die möglichen weiteren […]
Funny, created a All-In-One Powershell Linux Installation/Removal script using Microsoft’s Preferred Method about 12 days ago – with no extra options – and I landed on this page. Ouch. https://github.com/ronaldcotton/Linux-PowerShell-AIO-Installer
[…] doesn’t require to uninstall the old version before installing the new version. Inspired by Thomas Maurer’s post, I now use the following install-line. This also means that you don’t have to keep a second […]
The web pages shows
iex “& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI”
but should show
iex “& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI”
Hi
Yes my editor doesn’t like the special characters, so when I update the post, it changes some of the special characters. I fixed it again. Thank you!
It may be worth saying that the Powershell $PSVersionTable command (actually, variable) shows detailed version information on your installed powershell.
at my end, it doesn’t move an inch and have no idea why. When I say verbose, shouldn’t it show downloading the package or something. I have nothing at my end for all the efforts taken :(