-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoxStarter.ps1
306 lines (258 loc) · 8.31 KB
/
BoxStarter.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
#Requires -Version 3
#Requires -RunAsAdministrator
<#
$url = "https://raw.githubusercontent.com/sbugalski/boxstarter-win10/initial/BoxStarter.ps1"
. { Invoke-WebRequest -useb $url } | Invoke-Expression
#>
function Set-BoxstarterPrepare {
[CmdletBinding()]
param (
[Parameter()]
[Switch]
$logoutput
)
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
if ($logoutput) {
Start-Transcript -OutputDirectory $env:USERPROFILE\Desktop
get-date
}
# Create Powershell Profile, so chocolatey can append profile file. Later chocolatey commands are used.
if (! (Test-Path $profile)) {
New-Item -Path $profile -Type File -Force | Out-Null
}
# Install BoxStarter
. { Invoke-WebRequest -useb https://boxstarter.org/bootstrapper.ps1 } | Invoke-Expression; Get-Boxstarter -Force
# Load Chocolatey scripts
. $profile
### Set Boxstarter ###
$Boxstarter.RebootOk = $true # Allow reboots?
#$Boxstarter.NoPassword = $false # Is this a machine with no login password?
#$Boxstarter.AutoLogin = $true # Save my password securely and auto-login after a reboot
### Set Chocolatey
choco feature enable --name=allowGlobalConfirmation
}
### Functions
function Uninstall-Boxstarter {
# Remove the Chocolatey packages in a specific order!
'Boxstarter.Azure', 'Boxstarter.TestRunner', 'Boxstarter.WindowsUpdate', 'Boxstarter',
'Boxstarter.HyperV', 'Boxstarter.Chocolatey', 'Boxstarter.Bootstrapper', 'Boxstarter.WinConfig', 'BoxStarter.Common' |
ForEach-Object { choco uninstall $_ -y }
# Remove the Boxstarter data folder
Remove-Item -Path (Join-Path -Path $env:ProgramData -ChildPath 'Boxstarter') -Recurse -Force
# Remove Boxstarter from the path in both the current session and the system
$env:PATH = ($env:PATH -split ';' | Where-Object { $_ -notlike '*Boxstarter*' }) -join ';'
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, 'Machine')
# Remove Boxstarter from the PSModulePath in both the current session and the system
$env:PSModulePath = ($env:PSModulePath -split ';' | Where-Object { $_ -notlike '*Boxstarter*' }) -join ';'
[Environment]::SetEnvironmentVariable('PSModulePath', $env:PSModulePath, 'Machine')
}
function Invoke-Cleanup {
Write-Host "Cleaning desktop shortcuts"
Get-ChildItem -Path $env:PUBLIC\Desktop\*.lnk | Remove-Item
Get-ChildItem -Path $env:USERPROFILE\Desktop\*.lnk | Remove-Item
Get-ChildItem -Path $env:USERPROFILE\Desktop\*.ini | Remove-Item
choco feature disable --name=allowGlobalConfirmation
Get-Date
Stop-Transcript -ErrorAction "SilentlyContinue"
Uninstall-Boxstarter
}
function Install-ChocoApps ($packageArray) {
foreach ($package in $packageArray) {
choco install $package --limitoutput --ignoredependencies
}
if (Test-Path $profile) {
RefreshEnv
}
else {
# refreshenv doesn't work properly for Powershell, unless you set Chocolatey Profile https://github.com/chocolatey/choco/blob/master/src/chocolatey.resources/redirects/RefreshEnv.cmd#L11
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
}
}
function Set-ChocoPin ($packageArray) {
<#
Pin chocolatey package so it won't be auto updated when using choco upgrade
#>
foreach ($package in $packageArray) {
choco pin add --name $package
}
}
function Install-VsCodeExtensions ($packageArray) {
foreach ($package in $packageArray) {
code --install-extension $package
}
}
### Variables
### Tools
$chocoTools = @(
'7zip.install',
'sysinternals',
'teracopy',
'yubikey-manager',
'bulk-crap-uninstaller',
'calibre',
'chocolateygui',
'paint.net',
'powertoys',
'rdmfree',
'vlc',
'keepass.install',
'sharex',
'adobereader',
'github-desktop'
#'volume2.install',
#'rufus',
#'ccleaner.portable',
#'ccenhancer.portable',
#'winscp.install',
#'putty.install',
)
### Browsers
$chocoBrowsers = @(
# 'googlechrome',
# 'opera',
# 'microsoft-edge'
)
### Cloud
$chocoCloud = @(
'azure-cli',
'microsoftazurestorageexplorer',
'terraform',
'ARMClient',
'azcopy10'
#'awscli',
#'packer'
)
### Dev
$chocoDev = @(
'microsoft-windows-terminal',
'powershell-core',
'azure-data-studio',
'postman',
'cascadiafonts'
#'docker-desktop'
#'yarn'
#'python2',
#'python3',
#'golang',
#'gitkraken',
#'jetbrainstoolbox',
#'rsat',
#'nodejs.install',
)
### Editors
$chocoEditors = @(
'notepadplusplus.install',
'vscode'
#'vscodium'
)
### Work
$chocoWork = @(
#'microsoft-teams.install',
#'office365business',
#'google-drive-file-stream'
#'google-backup-and-sync'
)
$chocoLogi = @(
'logitech-options'
#'logitechgaming'
)
### Games
$chocoGames = @(
'steam',
'discord',
'spotify',
'goggalaxy',
'epicgameslauncher'
)
$chocoShellAddons = @(
'fzf',
'zoxide',
'az.powershell /core /desktop'
'azswitch',
'oh-my-posh'
)
$chocoK8s = @(
'kubernetes-cli',
'lens',
'kubernetes-helm',
'kubens',
'kubectx',
'kubelogin',
'octant',
'krew'
)
$chocoPin = @(
'adobereader',
$chocoBrowsers,
$chocoGames,
$chocoWork
)
$vsCodeExt = @(
#'2gua.rainbow-brackets',
#'CoenraadS.bracket-pair-colorizer-2',
#'eamodio.gitlens',
#'christian-kohler.path-intellisense'
)
#### Main ####
Set-BoxstarterPrepare -logoutput
### Personalization ###
Disable-BingSearch
Disable-GameBarTips
Set-TaskbarOptions -Size Small -Dock Left -UnLock -Combine Always
Set-CornerNavigationOptions -EnableUsePowerShellOnWinX
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions
### Windows features
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName Containers -All -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart
### Install Chocolatey packages
choco install git --package-parameters="'/GitOnlyOnPath /WindowsTerminal /SChannel /NoAutoCrlf'"
Install-ChocoApps $chocoTools
Install-ChocoApps $chocoBrowsers
Install-ChocoApps $chocoCloud
Install-ChocoApps $chocoDev
Install-ChocoApps $chocoEditors
Install-ChocoApps $chocoWork
Install-ChocoApps $chocoGames
Install-ChocoApps $chocoLogi
Install-ChocoApps $chocoShellAddons
Install-ChocoApps $chocoK8s
Set-ChocoPin $chocoPin
#Install-VsCodeExtensions $vsCodeExt
#npm install -g @mspnp/azure-building-blocks
#### Visual Studio
#choco install visualstudio2019enterprise --package-parameters "--add Microsoft.VisualStudio.Component.Git"
#### OpenVPN
#choco install openvpn --params "'/SELECT_LAUNCH=0'"
#### Python
#choco install miniconda3 --params="'/AddToPath:0 /InstallationType=AllUsers /RegisterPython=1 /D=C:\Program Files\miniconda3'"
#### Python PIP
#python -m pip install --upgrade pip
#conda update conda
#python2 -m pip install --upgrade pip
### Powershell
Install-PackageProvider -Name NuGet -Force
Update-Module -Force
Install-Module -Scope CurrentUser PSFzf
Install-Module -Scope CurrentUser WslInterop
### Configuration
# for some reason refreshenv does not affect git.exe
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
git config --global core.symlinks true
git config --global core.autocrlf input
git config --global core.eol lf
git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto
git config --global color.ui true
git config --global color.pager true
git config --global color.showbranch auto
Install-ChocolateyPinnedTaskBarItem -TargetFilePath "${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe"
Install-ChocolateyPinnedTaskBarItem -TargetFilePath "${env:ProgramFiles}\Opera\launcher.exe"
Install-ChocolateyPinnedTaskBarItem -TargetFilePath "${env:ProgramFiles}\Microsoft VS Code\Code.exe"
Install-ChocolateyPinnedTaskBarItem -TargetFilePath "${$env:windir}\explorer.exe"
### Finish ###
Enable-UAC
Invoke-Cleanup
Install-WindowsUpdate -GetUpdatesFromMS -AcceptEula -SuppressReboots