Install new WSL Preview for Windows 11+ and uninstall old one (#12)

- Windows 10 machines will get an error and do nothing.
main
Plínio Larrubia 3 years ago committed by Plínio Larrubia
parent bde2fa46ce
commit 66a4ce0bf5
No known key found for this signature in database
GPG Key ID: 057B0A87CB137C69

@ -61,6 +61,24 @@ function Optimize-OptionalFeatures() {
}
}
Try {
Write-Warning "[?] Installing WSL2 Preview from MS Store for Windows 11+..."
$CheckExistenceBlock = { winget install --source "msstore" --id 9P9TQF7MRM4R --accept-package-agreements }
$err = $null
$err = (Invoke-Expression "$CheckExistenceBlock") | Out-Host
if (($LASTEXITCODE)) { throw $err } # 0 = False, 1 = True
Write-Host "[-][Features] Uninstalling WSL from Optional Features..."
Get-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" | Where-Object State -Like "Enabled" | Disable-WindowsOptionalFeature -Online -NoRestart
}
Catch {
Write-Warning "[?] Couldn't install WSL2 Preview, you must be at least on Windows 11..."
}
}
function Main() {

Loading…
Cancel
Save