Install PowerShell on WSL2
Install PowerShell on Ubuntu 18.04
- Run the following commands to install PowerShell:
# Update the list of packagessudo apt-get update
# Install pre-requisite packages.sudo apt-get install -y wget apt-transport-https software-properties-common
# Download the Microsoft repository GPG keyswget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
# Register the Microsoft repository GPG keyssudo dpkg -i packages-microsoft-prod.deb
# Update the list of productssudo apt-get update
# Enable the "universe" repositoriessudo add-apt-repository universe
# Install PowerShellsudo apt-get install -y powershell
Test if you have install PowerShell successfully
- Run the following command:
$ pwsh -v
- You should get
PowerShell 7.1.3
version or a new version. - Now you are ready to use PowerShell on Linux.
- To start PowerShell session.
- Open a terminal and type
pwsh
.