mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-08 20:54:38 +02:00
Add install-wsl.ps1
This commit is contained in:
@ -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
38
Scripts/install-wsl.ps1
Executable 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
|
||||
}
|
@ -73,6 +73,7 @@ function ListTools {
|
||||
CheckFor cut "--version"
|
||||
CheckFor date ""
|
||||
CheckFor diff "--version"
|
||||
CheckFor dism ""
|
||||
CheckFor driverquery ""
|
||||
CheckFor find "--version"
|
||||
CheckFor ftp "--version"
|
||||
|
Reference in New Issue
Block a user