forked from patelcp/Sitecore-Dev-Machine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
box.ps1
535 lines (405 loc) · 18.8 KB
/
box.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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
# A BoxStarter script for use with http://boxstarter.org/WebLauncher
# Updates a Windows machine and installs a range of developer tools
# Allow unattended reboots
$Boxstarter.RebootOk=$true
$Boxstarter.NoPassword=$false
$Boxstarter.AutoLogin=$true
$checkpointPrefix = 'BoxStarter:Checkpoint:'
function Get-CheckpointName {
param
(
[Parameter(Mandatory=$true)]
[string]
$CheckpointName
)
return "$checkpointPrefix$CheckpointName"
}
function Set-Checkpoint {
param
(
[Parameter(Mandatory=$true)]
[string]
$CheckpointName,
[Parameter(Mandatory=$true)]
[string]
$CheckpointValue
)
$key = Get-CheckpointName $CheckpointName
[Environment]::SetEnvironmentVariable($key, $CheckpointValue, "Machine") # for reboots
[Environment]::SetEnvironmentVariable($key, $CheckpointValue, "Process") # for right now
}
function Get-Checkpoint {
param
(
[Parameter(Mandatory=$true)]
[string]
$CheckpointName
)
$key = Get-CheckpointName $CheckpointName
[Environment]::GetEnvironmentVariable($key, "Process")
}
function Clear-Checkpoints {
$checkpointMarkers = Get-ChildItem Env: | Where-Object { $_.name -like "$checkpointPrefix*" } | Select-Object -ExpandProperty name
foreach ($checkpointMarker in $checkpointMarkers) {
[Environment]::SetEnvironmentVariable($checkpointMarker, '', "Machine")
[Environment]::SetEnvironmentVariable($checkpointMarker, '', "Process")
}
}
function Get-SystemDrive {
return $env:SystemDrive[0]
}
function Install-ClickOnceApp {
param(
$ApplicationName,
$WebLauncherUrl
)
$edgeVersion = Get-AppxPackage -Name Microsoft.MicrosoftEdge
if ($edgeVersion) {
Start-Process microsoft-edge:$webLauncherUrl
}
else {
$IE=new-object -com internetexplorer.application
$IE.navigate2($webLauncherUrl)
$IE.visible=$true
}
}
function Install-InternetInformationServices {
$checkpoint = 'InternetInformationServices'
$done = Get-Checkpoint -CheckpointName $checkpoint
if ($done) {
Write-BoxstarterMessage "$checkpoint are already installed"
return
}
# Enable Internet Information Services Feature - will enable a bunch of things by default
choco install IIS-WebServerRole --source windowsfeatures --limitoutput
# Web Management Tools Features
choco install IIS-ManagementScriptingTools --source windowsfeatures --limitoutput
choco install IIS-IIS6ManagementCompatibility --source windowsfeatures --limitoutput # installs IIS Metbase
# Common Http Features
choco install IIS-HttpRedirect --source windowsfeatures --limitoutput
# .NET Framework 4.5/4.6 Advance Services
choco install NetFx4Extended-ASPNET45 --source windowsfeatures --limitoutput # installs ASP.NET 4.5/4.6
# Application Development Features
choco install IIS-NetFxExtensibility45 --source windowsfeatures --limitoutput # installs .NET Extensibility 4.5/4.6
choco install IIS-ISAPIFilter --source windowsfeatures --limitoutput # required by IIS-ASPNET45
choco install IIS-ISAPIExtensions --source windowsfeatures --limitoutput # required by IIS-ASPNET45
choco install IIS-ASPNET45 --source windowsfeatures --limitoutput # installs support for ASP.NET 4.5/4.6
choco install IIS-ApplicationInit --source windowsfeatures --limitoutput
# Health And Diagnostics Features
choco install IIS-LoggingLibraries --source windowsfeatures --limitoutput # installs Logging Tools
choco install IIS-RequestMonitor --source windowsfeatures --limitoutput
choco install IIS-HttpTracing --source windowsfeatures --limitoutput
choco install IIS-CustomLogging --source windowsfeatures --limitoutput
# Performance Features
choco install IIS-HttpCompressionDynamic --source windowsfeatures --limitoutput
# Security Features
choco install IIS-BasicAuthentication --source windowsfeatures --limitoutput
#choco install UrlRewrite2 --source webpi --limitoutput
Set-Checkpoint -CheckpointName $checkpoint -CheckpointValue 1
}
function Install-NpmPackages {
$checkpoint = 'NpmPackages'
$done = Get-Checkpoint -CheckpointName $checkpoint
if ($done) {
Write-BoxstarterMessage "$checkpoint are already installed"
return
}
npm install -g gulp-cli
npm install -g bower
npm install -g yo
npm install -g generator-helix
Set-Checkpoint -CheckpointName $checkpoint -CheckpointValue 1
}
function Install-PowerShellModules {
$checkpoint = 'PowerShellModules'
$done = Get-Checkpoint -CheckpointName $checkpoint
if ($done) {
Write-BoxstarterMessage "$checkpoint are already installed"
return
}
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Set-PSRepository -Name 'PSGallery' -InstallationPolicy 'Trusted'
Install-Module -Name Carbon
Install-Module -Name PowerShellHumanizer
Set-PSRepository -Name 'PSGallery' -InstallationPolicy 'Untrusted'
Set-Checkpoint -CheckpointName $checkpoint -CheckpointValue 1
}
function Install-RequiredApps {
$checkpoint = 'RequiredApps'
$done = Get-Checkpoint -CheckpointName $checkpoint
if ($done) {
Write-BoxstarterMessage "$checkpoint are already installed"
return
}
choco install nodejs.install --limitoutput
choco install googlechrome --limitoutput
choco install firefox --limitoutput
choco install flashplayerplugin --limitoutput
choco install adobereader --limitoutput
#choco install nugetpackageexplorer --limitoutput
refreshenv
Set-Checkpoint -CheckpointName $checkpoint -CheckpointValue 1
}
function Install-RecommendedApps {
$checkpoint = 'RecommendedApps'
$done = Get-Checkpoint -CheckpointName $checkpoint
if ($done) {
Write-BoxstarterMessage "$checkpoint are already installed"
return
}
choco install jdk8 --limitoutput
choco install git.install --limitoutput
choco install fiddler4 --limitoutput
choco install nuget.commandline --limitoutput
choco install notepadplusplus.install --limitoutput --x86
choco install linqpad4.install --limitoutput
#choco install poshgit --limitoutput
choco install sourcetree --limitoutput
choco install dotpeek --limitoutput
choco install prefix --limitoutput --allow-empty-checksums-secure
Set-Checkpoint -CheckpointName $checkpoint -CheckpointValue 1
}
function Install-SitecoreTools{
$checkpoint = 'SitecoreTools'
$done = Get-Checkpoint -CheckpointName $checkpoint
if ($done) {
Write-BoxstarterMessage "$checkpoint are already installed"
return
}
$sitecoreToolsPath = "$dataDrive\Sitecore\tools"
if(-not (Test-Path $sitecoreToolsPath)) {
New-Item $sitecoreToolsPath -ItemType Directory
}
Install-ChocolateyZipPackage -allowEmptyChecksumsSecure -PackageName "Sitecore Config Builder 1.4" `
-Url "https://github.com/Sitecore/Sitecore-Config-Builder/releases/download/1.4.0.20/SCB.1.4.0.20.zip" `
-UnzipLocation "$sitecoreToolsPath\ConfigBuilder" -checksum "a254e7571b2c488c973d2d3edb609bc8"
Install-ChocolateyZipPackage -allowEmptyChecksumsSecure -PackageName "Sitecore Log Analyzer" `
-Url "https://marketplace.sitecore.net/services/~/media/A99BCECAD8B44DA8B2CB27FC0BC6DD05.ashx?data=SCLA%202.0.0%20rev.%20140603&itemId=420d8d66-cc7f-4b59-a936-16c18cac13da" `
-UnzipLocation "$sitecoreToolsPath\LogAnalyzer" -checksum "f1a6ed38a86daa9ec247b0dd67611f7d"
Install-ClickOnceApp -ApplicationName "Sitecore Instance Manager" -WebLauncherUrl "http://dl.sitecore.net/updater/sim/SIM.Tool.application"
Install-ClickOnceApp -ApplicationName "Sitecore Diagnostics Toolset" -WebLauncherUrl "http://dl.sitecore.net/updater/sdt/Sitecore.DiagnosticsToolset.WinApp.application"
}
function Install-SQLServerExpress{
$checkpoint = 'SQLServerExpress'
$done = Get-Checkpoint -CheckpointName $checkpoint
if ($done) {
Write-BoxstarterMessage "$checkpoint are already installed"
return
}
choco install mssqlserver2014express --limitoutput
choco install mssqlservermanagementstudio2014express --limitoutput
Set-Checkpoint -CheckpointName $checkpoint -CheckpointValue 1
}
function Install-VisualStudio {
# install visual studio 2015
$VSCheckpoint = 'VisualStudio'
$VSDone = Get-Checkpoint -CheckpointName $VSCheckpoint
if ($done) {
Write-BoxstarterMessage "$checkpoint are already installed"
return
}
# choco install visualstudio2015community --limitoutput # -packageParameters "--AdminFile https://raw.githubusercontent.com/JonCubed/boxstarter/master/config/AdminDeployment.xml"
choco install VisualStudio2015Professional -packageParameters "WebTools SQL" --limitoutput
Set-Checkpoint -CheckpointName $VSCheckpoint -CheckpointValue 1
}
function Install-VisualStudioExtensionsRequired {
param (
$DownloadFolder
)
$checkpoint = 'VSRequiredExtensions'
$done = Get-Checkpoint -CheckpointName $checkpoint
if ($done) {
Write-BoxstarterMessage "$checkpoint are already installed"
return
}
Install-ChocolateyVsixPackage 'Web Essentials 2015.3' https://visualstudiogallery.msdn.microsoft.com/ee6e6d8c-c837-41fb-886a-6b50ae2d06a2/file/146119/48/Web%20Essentials%202015.3%20v3.0.235.vsix
Install-ChocolateyVsixPackage 'Sitecore Rocks' https://visualstudiogallery.msdn.microsoft.com/44a26c88-83a7-46f6-903c-5c59bcd3d35b/file/35439/48/Sitecore.Rocks.VisualStudio.vsix
Install-ChocolateyVsixPackage 'StyleCop' https://visualstudiogallery.msdn.microsoft.com/5441d959-387f-4cb2-a8c0-9998dd1fa49f/file/231103/2/StyleCop.vsix
Install-WebPackage '.NET Core Visual Studio Extension' 'exe' '/quiet' $DownloadFolder https://go.microsoft.com/fwlink/?LinkID=827546 'DotNetCore.1.0.1-VS2015Tools.Preview2.0.3.exe' # for visual studio
Set-Checkpoint -CheckpointName $checkpoint -CheckpointValue 1
}
function Install-VisualStudioExtensionsRecommended {
$checkpoint = 'VSRecommendedExtensions'
$done = Get-Checkpoint -CheckpointName $checkpoint
if ($done) {
Write-BoxstarterMessage "$checkpoint are already installed"
return
}
Install-ChocolateyVsixPackage 'Productivity Power Tools 2015' https://visualstudiogallery.msdn.microsoft.com/34ebc6a2-2777-421d-8914-e29c1dfa7f5d/file/169971/3/ProPowerTools.vsix
Install-ChocolateyVsixPackage 'PowerShell Tools for Visual Studio 2015' https://visualstudiogallery.msdn.microsoft.com/c9eb3ba8-0c59-4944-9a62-6eee37294597/file/199313/3/PowerShellTools.14.0.vsix
Install-ChocolateyVsixPackage 'Spell Checker' https://visualstudiogallery.msdn.microsoft.com/7c8341f1-ebac-40c8-92c2-476db8d523ce/file/15808/12/SpellChecker.vsix
Install-ChocolateyVsixPackage 'Web Compiler' https://visualstudiogallery.msdn.microsoft.com/3b329021-cd7a-4a01-86fc-714c2d05bb6c/file/164873/35/Web%20Compiler%20v1.10.300.vsix
Install-ChocolateyVsixPackage 'Web Analyzer' https://visualstudiogallery.msdn.microsoft.com/6edc26d4-47d8-4987-82ee-7c820d79be1d/file/181923/24/Web%20Analyzer%20v1.7.77.vsix
Install-ChocolateyVsixPackage 'Markdown Editor' https://visualstudiogallery.msdn.microsoft.com/eaab33c3-437b-4918-8354-872dfe5d1bfe/file/216970/26/Markdown%20Editor%20v1.11.201.vsix
Install-ChocolateyVsixPackage 'Gulp Snippet Pack' https://visualstudiogallery.msdn.microsoft.com/9e26d1f9-1baf-4983-8c25-f5f769998d4f/file/205735/4/Gulp%20Snippet%20Pack%20v1.2.6.vsix
Set-Checkpoint -CheckpointName $checkpoint -CheckpointValue 1
}
function Install-VisualStudioCode {
$checkpoint = 'VSCode'
$done = Get-Checkpoint -CheckpointName $checkpoint
if ($done) {
Write-BoxstarterMessage "$checkpoint are already installed"
return
}
# install visual studio code and extensions
choco install visualstudiocode --limitoutput
Update-Path
# need to launch vscode so user folders are created as we can install extensions
Start-Process code
Start-Sleep -s 10
code --install-extension ms-vscode.csharp
code --install-extension ms-vscode.PowerShell
code --install-extension msazurermtools.azurerm-vscode-tools
code --install-extension robertohuertasm.vscode-icons
code --install-extension DavidAnson.vscode-markdownlint
#code --install-extension msjsdiag.debugger-for-chrome
Set-Checkpoint -CheckpointName $checkpoint -CheckpointValue 1
}
function Install-WindowsUpdates {
if (Test-Path env:\BoxStarter:SkipWindowsUpdate) {
return
}
Write-BoxstarterMessage "Installing Windows update and reboot if necessary!"
Enable-MicrosoftUpdate
Install-WindowsUpdate -AcceptEula
#if (Test-PendingReboot) { Invoke-Reboot }
}
function Install-WebPackage {
param(
$packageName,
[ValidateSet('exe', 'msi')]
$fileType,
$installParameters,
$downloadFolder,
$url,
$filename
)
$done = Get-Checkpoint -CheckpointName $packageName
if ($done) {
Write-BoxstarterMessage "$packageName already installed"
return
}
if ([String]::IsNullOrEmpty($filename)) {
$filename = Split-Path $url -Leaf
}
$fullFilename = Join-Path $downloadFolder $filename
if (test-path $fullFilename) {
Write-BoxstarterMessage "$fullFilename already exists"
return
}
Get-ChocolateyWebFile $packageName $fullFilename $url
Install-ChocolateyInstallPackage $packageName $fileType $installParameters $fullFilename
Set-Checkpoint -CheckpointName $packageName -CheckpointValue 1
}
function Set-BaseSettings {
$checkpoint = 'BaseSettings'
$done = Get-Checkpoint -CheckpointName $Checkpoint
if ($done) {
Write-BoxstarterMessage "$checkpoint are already installed"
return
}
Update-ExecutionPolicy -Policy Unrestricted
# install chocolatey
choco install chocolatey --limitoutput
$sytemDrive = Get-SystemDrive
#Set-Volume -DriveLetter $sytemDrive -NewFileSystemLabel "System"
# Show more info for files in Explorer
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -DisableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar
# Small taskbar
Set-TaskbarOptions -Combine Always
# replace command prompt with powershell in start menu and win+x
Set-CornerNavigationOptions -EnableUsePowerShellOnWinX
# Disable hibernate
#Start-Process 'powercfg.exe' -Verb runAs -ArgumentList '/h off'
refreshenv
Set-Checkpoint -CheckpointName $checkpoint -CheckpointValue 1
}
function Set-ChocoRequiredAppPins {
# pin apps that update themselves
#choco pin add -n=VisualStudio2015Professional
#choco pin add -n=mssqlserver2014express
choco pin add -n=googlechrome
choco pin add -n=firefox
#choco pin add -n=visualstudio2015community
}
function Set-ChocoRecommendedAppPins {
# pin apps that update themselves
choco pin add -n=visualstudiocode
choco pin add -n=sourcetree
}
function Set-RequiredAppSettings {
# The Install-ChocolateyPinnedTaskBarItem is broken in Windows 10: https://github.com/chocolatey/choco/issues/627
#Install-ChocolateyPinnedTaskBarItem "$($Boxstarter.programFiles86)\Google\Chrome\Application\chrome.exe" -ErrorAction SilentlyContinue
#Install-ChocolateyPinnedTaskBarItem "$($Boxstarter.programFiles86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe" -ErrorAction SilentlyContinue
}
function Set-RecommendedAppSettings {
# The Install-ChocolateyPinnedTaskBarItem is broken in Windows 10: https://github.com/chocolatey/choco/issues/627
#Install-ChocolateyPinnedTaskBarItem "${env:ProgramFiles(x86)}\Fiddler2\Fiddler.exe" -ErrorAction SilentlyContinue
#Install-ChocolateyPinnedTaskBarItem "$($Boxstarter.programFiles86)\Microsoft VS Code\Code.exe" -ErrorAction SilentlyContinue
#Install-ChocolateyPinnedTaskBarItem "${env:ProgramFiles(x86)}\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\Ssms.exe" -ErrorAction SilentlyContinue
Install-ChocolateyFileAssociation ".txt" "${env:ProgramFiles(x86)}\Notepad++\notepad++.exe" -ErrorAction SilentlyContinue
Install-ChocolateyFileAssociation ".dll" "$env:LOCALAPPDATA\JetBrains\Installations\dotPeek06\dotPeek64.exe" -ErrorAction SilentlyContinue
}
function New-InstallCache {
param
(
[String]
$InstallDrive
)
$tempInstallFolder = Join-Path $InstallDrive "temp\install-cache"
if(-not (Test-Path $tempInstallFolder)) {
New-Item $tempInstallFolder -ItemType Directory
}
return $tempInstallFolder
}
function Update-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
}
$dataDriveLetter = Get-SystemDrive
$dataDrive = "$dataDriveLetter`:"
$tempInstallFolder = New-InstallCache -InstallDrive $dataDrive
# SQL Server requires some KB patches before it will work, so windows update first
#Install-WindowsUpdates
# disable chocolatey default confirmation behaviour (no need for --yes)
choco feature enable --name=allowGlobalConfirmation
Set-BaseSettings
Write-BoxstarterMessage "Starting installs"
if (-not (Test-Path env:\BoxStarter:SkipInstallRequiredApps)) {
Write-BoxstarterMessage "Installing Required apps"
Install-InternetInformationServices
#Install-RequiredApps
#Install-NpmPackages
#Install-SQLServerExpress
#Install-VisualStudio
#Install-VisualStudioExtensionsRequired -DownloadFolder $tempInstallFolder
# pin chocolatey app that self-update
Set-ChocoRequiredAppPins
# Add App shortcuts on taskbar
Set-RequiredAppSettings
}
if (-not (Test-Path env:\BoxStarter:SkipSitcoreTools)) {
Write-BoxstarterMessage "Installing Sitecore Tools"
Install-SitecoreTools
}
if (-not (Test-Path env:\BoxStarter:SkipInstallRecommendedApps)) {
Write-BoxstarterMessage "Installing Recommended apps"
Install-RecommendedApps
Install-VisualStudioCode
# pin chocolatey app that self-update
Set-ChocoRecommendedAppPins
# Add App shortcuts on taskbar
Set-RecommendedAppSettings
}
# re-enable chocolatey default confirmation behaviour
choco feature disable --name=allowGlobalConfirmation
if (Test-PendingReboot) {
Invoke-Reboot
}
# reload path environment variable
Update-Path
#Install-PowerShellModules
# set HOME to user profile for git
[Environment]::SetEnvironmentVariable("HOME", $env:UserProfile, "User")
# rerun windows update after we have installed everything
#Install-WindowsUpdates
Clear-Checkpoints