Skip to content

Instantly share code, notes, and snippets.

@starise
Forked from yuntsewu/enable-bash.ps1
Created September 24, 2017 10:21
Show Gist options
  • Save starise/29079f3c3f929695c2c4b174c98851c4 to your computer and use it in GitHub Desktop.
Save starise/29079f3c3f929695c2c4b174c98851c4 to your computer and use it in GitHub Desktop.
On Windows 10, right click and press "Run with PowerShell" will install "Windows Subsystem for Linux" on your system. After it completes, Win+R -> bash will prompt you for the initialization.
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
# Create AppModelUnlock if it doesn't exist, required for enabling Developer Mode
$RegistryKeyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock"
if (-not(Test-Path -Path $RegistryKeyPath)) {
New-Item -Path $RegistryKeyPath -ItemType Directory -Force
}
# Add registry value to enable Developer Mode
New-ItemProperty -Path $RegistryKeyPath -Name AllowDevelopmentWithoutDevLicense -PropertyType DWORD -Value 1
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment