Add install-wsl.ps1

This commit is contained in:
Markus Fleschutz
2021-08-02 20:45:34 +02:00
parent 1cee5b6ae2
commit 829e04afe1
5 changed files with 46 additions and 1 deletions

View File

@ -12,12 +12,16 @@
#>
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()
$Path = $env:TEMP;
$Installer = "chrome_installer.exe"
Invoke-WebRequest "http://dl.google.com/chrome/install/latest/chrome_installer.exe" -OutFile $Path\$Installer
Start-Process -FilePath $Path\$Installer -Args "/silent /install" -Verb RunAs -Wait
Remove-Item $Path\$Installer
write-host -foregroundColor green "✔️ installed Google Chrome"
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ installed Google Chrome in $Elapsed sec"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

38
Scripts/install-wsl.ps1 Executable file
View File

@ -0,0 +1,38 @@
<#
.SYNOPSIS
install-wsl.ps1
.DESCRIPTION
Installs Windows Subsystem for Linux (WSL) - needs administrator rights
.EXAMPLE
PS> .\install-wsl.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
#>
#Requires -RunAsAdministrator
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()
if ($false) {
& wsl --install
} else {
& dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
& dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
& wsl --set-default-version 2
}
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ installed Windows Subsystem for Linux (WSL) in $Elapsed sec"
" NOTE: reboot now, then visit the Microsoft Store and install a Linux distribution (e.g. Ubuntu, openSUSE, SUSE Linux, Kali Linux, Debian, Fedora, Pengwin, or Alpine)"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}

View File

@ -73,6 +73,7 @@ function ListTools {
CheckFor cut "--version"
CheckFor date ""
CheckFor diff "--version"
CheckFor dism ""
CheckFor driverquery ""
CheckFor find "--version"
CheckFor ftp "--version"