-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_windows_vm.ps1
141 lines (124 loc) · 4.51 KB
/
setup_windows_vm.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<# Instruction
0. Finish all available Windows update (Preferably also activiate Windows)
1. Update the `App Installer` in Microsoft Store
2. Start an elevated Powershell prompt, run `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force`, then run this script
TODO:
- Add error handling
- Automate winget installation with https://github.com/microsoft/winget-cli/discussions/1738#discussioncomment-5484927
#>
if (Test-Path env:TEMP) {
Push-Location $env:TEMP
}
elseif (Test-Path env:tmp) {
Push-Location $env:TMP
}
else {
Write-Host "No temp folder in PATH, quitting..."
exit 1
}
# Uninstall bloatware
Write-Host "Uninstalling bloatware..."
$bloatwares = @(
"Microsoft.Microsoft3DViewer",
"Microsoft.WindowsAlarms",
# Mail, Calendar
"Microsoft.windowscommunicationsapps",
# Cortana
"Microsoft.549981C3F5F10",
"Microsoft.WindowsFeedbackHub",
# Groove Music
"Microsoft.ZuneMusic",
# Movies & TV
"Microsoft.ZuneVideo",
# Paint 3D
"Microsoft.MSPaint",
"Microsoft.WindowsMaps",
"Microsoft.MicrosoftSolitaireCollection",
"Microsoft.MixedReality.Portal",
"Microsoft.Office.OneNote",
"Microsoft.MicrosoftOfficeHub",
"Microsoft.XboxApp",
"Microsoft.BingWeather",
"Microsoft.MicrosoftStickyNotes",
"Microsoft.SkypeApp",
"Microsoft.ScreenSketch",
"Microsoft.People",
"Microsoft.Windows.Photos",
"Microsoft.WindowsSoundRecorder",
"Microsoft.WindowsCamera"
)
foreach ($bloatware in $bloatwares) {
Get-AppxPackage $bloatware | Remove-AppxPackage
}
# Check for winget
try {
# Powershell try-catch works only when the error is terminating
Get-Command winget -ErrorAction Stop
}
catch {
Write-Host "Winget not found, please update the `App Installer` in Microsoft Store!"
exit 1
}
# Install packages
Write-Host "Installing common packages..."
$packages = @(
"7zip.7zip",
"Apple.iTunes",
"DuongDieuPhap.ImageGlass",
"Git.Git",
"gerardog.gsudo",
"JanDeDobbeleer.OhMyPosh",
"jdx.mise",
"Microsoft.PowerShell",
"Microsoft.WindowsTerminal",
"Mozilla.Firefox",
"Notepad++.Notepad++",
"okibcn.nano",
"PeterPawlowski.foobar2000",
"qBittorrent.qBittorrent",
"RaspberryPiFoundation.RaspberryPiImager",
"TheDocumentFoundation.LibreOffice",
"twpayne.chezmoi",
"VideoLAN.VLC"
)
foreach ($package in $packages) {
winget install --id=$package -e --accept-package-agreements --accept-source-agreements --source winget
}
# Setup Chezmoi
chezmoi init --apply --force regunakyle
oh-my-posh font install NerdFontsSymbolsOnly
# SSH server for ProxyJump
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
# Confirm the Firewall rule is configured. It should be created automatically by setup.
if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) {
Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..."
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
} else {
Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists."
}
# Trader Workstation from IBKR
Write-Host "Installing Trader Workstation..."
Invoke-WebRequest https://download2.interactivebrokers.com/installers/tws/latest/tws-latest-windows-x64.exe `
-OutFile tws-latest-windows-x64.exe
$install = Start-Process -FilePath .\tws-latest-windows-x64.exe -ArgumentList "-q" -PassThru
while (!$install.HasExited) {
Write-Host "Waiting for TWS installation to complete..."
Start-Sleep -Seconds 3
}
Remove-Item .\tws-latest-windows-x64.exe
if ((Get-CimInstance win32_VideoController).Name | Select-String "Nvidia") {
Write-Host "Installing desktop packages..."
$packages = @(
"Discord.Discord",
"Valve.Steam"
)
foreach ($package in $packages) {
winget install --id=$package -e --accept-package-agreements --accept-source-agreements --source winget
}
# https://github.com/microsoft/winget-pkgs/issues/140696
Write-Host "You should install the Nvidia App manually."
}
Write-Host "Installation finished! You should reboot now to avoid stability problems."
Write-Host "You should also install Mise plugins manually in Powershell Core."
Pop-Location