Skip to content

Instantly share code, notes, and snippets.

@antoniordo
Created September 21, 2020 17:48
Show Gist options
  • Save antoniordo/dbe5bf4fe08d5f4c6fce29791dcb86eb to your computer and use it in GitHub Desktop.
Save antoniordo/dbe5bf4fe08d5f4c6fce29791dcb86eb to your computer and use it in GitHub Desktop.
Enable Windows 10 WSL 2 and install Ubuntu 20.04 LTS
# How to use:
# 1) Open power shell in administrator mode
# 2) Execute command:
# Set-ExecutionPolicy Unrestricted -Force
# 3) Execute this script:
# & .\configure-wsl2-ubuntu-lts.ps1
# 4) Restart computer
echo "Enabling WSL..."
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
echo "Installing WSL 2 update..."
Invoke-WebRequest -Uri https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi -OutFile $HOME/Downloads/wsl_update_x64.msi
& $HOME\Downloads\wsl_update_x64.msi /quiet /passive
echo "Setting WSL 2 as default..."
wsl --set-default-version 2
echo "Installing Ubuntu LTS distro..."
Invoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile $HOME/Downloads/Ubuntu.appx
Add-AppxPackage -Path $HOME\Downloads\Ubuntu.appx
echo "Please restart "
$a = new-object -comobject wscript.shell
$intAnswer = $a.popup("Restart system to complete instalation?", `
0,"Restart",4)
If ($intAnswer -eq 6) {
Restart-Computer
} else {
echo "Restart system manually to complete installation"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment