PowerShell 7 is the new cross-platform version of PowerShell and can be installed on a wide range of operating systems, including Windows, Linux, MacOS.
Installation takes just a few seconds. PowerShell 7 has grown up considerably: while it can’t (yet) do everything that is possible in Windows PowerShell, it might be a fast alternative to the automation tasks it can handle, and a good start to get used to it.
Quick Words
PowerShell 7 is built on the cross-platform .NET Core. This ensures that it is available across platforms, but is also the reason why PowerShell 7 currently does not support all PowerShell Modules and may lack certain capabilities.
It currently does not support window elements (and as such does not include Out-GridView
either). Also older PowerShell Modules might not yet be compatible. That said, it is impressive how compatible PowerShell 7 still is.
Because of the potential incompatibilities, PowerShell 7 uses its own module paths (take a look at $env:psmodulepath
). You may need to install modules again using Install-Module
from within PowerShell 7, or manually copy compatible modules.
Installing on Windows
Use the existing Windows PowerShell to download the official installation script from Microsoft, turn it into a function, then use it to download and install PowerShell Core.
PowerShell Core is a portable app and won’t interfere with the existing Windows PowerShell installation. After you installed PowerShell Core, you simply have two PowerShell environments run
powershell.exe
to open the cozy Windows PowerShell, and runpwsh.exe
to launch the new PowerShell Core.
# download the installation code
$code = Invoke-RestMethod -Uri https://aka.ms/install-powershell.ps1
# turn it into a function
$null = New-Item -Path function:Install-PowerShell -Value $code
# run the function
Install-PowerShell -UseMSI -Preview
Install-PowerShell
downloads and installs the appropriate version for you. Above script downloads and installs the latest preview version via MSI Installer. Remove -Preview to get the latest official and stable release.
Parameter | Description |
---|---|
Destination | Path where PowerShell Core should be installed |
Daily | Install from Daily Build (the super freshest build) |
Preview | Install the latest preview build (currently PowerShell 7) |
UseMSI | Use the MSI Installer for installation |
Quiet | Install without user interaction (MSI) |
DoNotOverwrite | Do not overwrite an existing destination folder |
AddToPath | Add the installation path to the environment variable %PATH% so that you can run pwsh from any directory to launch PowerShell |
Test-Drive the Preview
Most of the exciting new features surface in PowerShell 7. This version is not yet released as I write this, so if you want to play with the “new” PowerShell, I strongly recommend that you test-drive the latest preview release by using the parameter -Preview.
Launching PowerShell
Once PowerShell is installed, you can launch it via pwsh
, for example from within your PowerShell Console:
pwsh
If Windows PowerShell can’t find the command, then you may have opted out to add the path to PowerShell to your $env:path environment variable. In this case, you need to specify the full absolute path to pwsh.exe.
Check $env:path
To check whether pwsh.exe was added to the environment variable, run this:
$env:path -split ';'
This lists all folders that Windows searches when you specify an executable without full path. There should be an entry like this:
C:\Program Files\PowerShell\7-preview\preview
Installing On Linux
To install PowerShell on Linux, run this line:
wget https://aka.ms/install-powershell.sh; sudo bash install-powershell.sh -preview; rm install-powershell.sh
Contributing
PowerShell is driven by a vibrant community. It is open-source, and you should visit github.com/PowerShell/PowerShell as a starting point.
Look at the source code, contribute yourself by working on the code, or report bugs or submit feature requests and new ideas here.
Before you file any of these, you should take a minute and browse through the existing submissions and make sure you are not producing duplicate effort.