forked from tomjoht/documentation-theme-jekyll
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathInstallWSL-Step1.ps1
executable file
·38 lines (32 loc) · 1.54 KB
/
InstallWSL-Step1.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
workflow InstallWSL-USBIPD {
#Install WSL2 and setup Ubuntu
Start-Process powershell -Verb RunAs -ArgumentList 'wsl --install' -Wait
#Download usbipd-win_2.3.0.msi
Start-Process "winget.exe" -ArgumentList "install", "--silent", "--exact dorssel.usbipd-win" -Wait
}
InstallWSL-USBIPD
#USB GUI Prompt
$PromptGui = New-Object -comobject wscript.shell
$AnswerGui = $PromptGui.Popup("Would you like to install WSL USB GUI? This is a GUI for attaching and removing USB devices from WSL.", 60, "Install WSL GUI?", 4096 + 48 + 1)
Switch ($AnswerGui) {
# Accepted #
{ $AnswerGui -eq 1 } {
#Download WSL-USB-3.2-g4a21d53.msi
Invoke-RestMethod "https://gitlab.com/api/v4/projects/35133362/packages/generic/wsl-usb-gui/3.2/WSL-USB-3.2-g4a21d53.msi" -OutFile $env:USERPROFILE\Downloads\WSL-USB-3.2-g4a21d53.msi
#Install WSL-USB-3.2-g4a21d53.msi
Start-Process "msiexec.exe" -ArgumentList "/I", "$env:USERPROFILE\Downloads\WSL-USB-3.2-g4a21d53.msi /quiet" -Wait
}
# Cancelled #
{ $AnswerGui -eq 2 } { Exit 0 }
}
#Restart Computer
$Prompt = New-Object -comobject wscript.shell
$Answer = $Prompt.Popup("WARNING: WSL requires reboot after first setting up, PC will reboot in 60 seconds", 60, "Restart", 4096 + 48 + 1)
Switch ($Answer) {
# Accepted #
{ $Answer -eq 1 } { Start-Sleep -Seconds 60; Restart-Computer -Force }
# Cancelled #
{ $Answer -eq 2 } { Exit 0 }
# Timeout #
{ $Answer -eq -1 } { Start-Sleep -Seconds 60; Restart-Computer -Force }
}