-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathboxstarter.ps1
More file actions
138 lines (108 loc) · 4.24 KB
/
boxstarter.ps1
File metadata and controls
138 lines (108 loc) · 4.24 KB
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
# Adapted from http://www.west-wind.com/Weblog/posts/197245.aspx
function Get-FileEncoding($Path) {
$bytes = [byte[]](Get-Content $Path -Encoding byte -ReadCount 4 -TotalCount 4)
if(!$bytes) { return 'utf8' }
switch -regex ('{0:x2}{1:x2}{2:x2}{3:x2}' -f $bytes[0],$bytes[1],$bytes[2],$bytes[3]) {
'^efbbbf' { return 'utf8' }
'^2b2f76' { return 'utf7' }
'^fffe' { return 'unicode' }
'^feff' { return 'bigendianunicode' }
'^0000feff' { return 'utf32' }
default { return 'ascii' }
}
}
#Boxstarter options
$Boxstarter.RebookOk=$true #allow reboots
$Boxstarter.NoPassword=$false #we have a password
$Boxstarter.AutoLogin=$true #save my password and use it to login after reboots
#living on the edge
Update-ExecutionPolicy Unrestricted
[Environment]::SetEnvironmentVariable('GIT_SSH', 'plink.exe', 'Machine')
if($env:BoxStarterScriptsRoot -eq $null)
{
[Environment]::SetEnvironmentVariable('BoxStarterScriptsRoot', 'https://raw.githubusercontent.com/luke-barnett/boxstarter-scripts/master/', 'User')
}
if($env:PowerShellScriptsRepo -eq $null)
{
[Environment]::SetEnvironmentVariable('PowerShellScriptsRepo', 'https://github.com/luke-barnett/powershell-scripts', 'User')
}
#Windows customisations
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFileExtension -EnableShowFullPathInTitleBar
Disable-InternetExplorerESC #servers be dammed
Disable-BingSearch
Disable-UAC
Install-WindowsUpdate -AcceptEula -SuppressReboots -GetUpdatesFromMS
#reboot if needed
if (Test-PendingReboot) { Invoke-Reboot }
#.NET 3.5 reboot if we need to
cinst -y DotNet3.5 powershell
if (Test-PendingReboot) { Invoke-Reboot }
#HyperV reboot if we need to
cinst -y Microsoft-Hyper-V-All -source windowsFeatures
if (Test-PendingReboot) { Invoke-Reboot }
#Browsers
cinst -y googlechrome firefox
#Text editors
cinst -y sublimetext3 visualstudiocode
#Development tools
cinst -y fiddler4 ilspy linqpad nuget.commandline nugetpackageexplorer windowsazurepowershell sql-server-management-studio docker-for-windows
#git
cinst -y git git-credential-manager-for-windows poshgit
cinst -y gitversion.portable
cinst -y sourcetree tortoisegit
#visual studio 2017
cinst -y visualstudio2017professional
cinst -y visualstudio2017-workload-azure visualstudio2017-workload-data visualstudio2017-workload-manageddesktop visualstudio2017-workload-netcoretools
cinst -y visualstudio2017-workload-netcrossplat visualstudio2017-workload-netweb visualstudio2017-workload-node visualstudio2017-workload-office visualstudio2017-workload-universal
cinst -y visualstudio2017-workload-webcrossplat visualstudio2017-workload-visualstudioextension
#Runtimes
cinst -y nodejs yarn
#Utilities
cinst -y boxstarter checksum bind-toolsonly azcopy filezilla putty
cinst -y royalts spotify vlc windirstat 7zip grammarly
cinst -y resilio-sync-home spideroakone qbittorrent acestream
Write-Output 'Install common npm global packages'
npm install -g eslint grunt-cli gulp-cli http-server iisexpress-proxy jshint rimraf npm-windows-upgrade
Write-Output 'Pinning chocolatey packages'
choco pin add -n=googlechrome
choco pin add -n=visualstudiocode
$codeDirectory = 'C:\code'
$scriptsDirectory = $codeDirectory + '\powershell-scripts'
if(!(test-path $codeDirectory))
{
New-Item -ItemType directory -Path $codeDirectory
}
if(test-path $scriptsDirectory\.git)
{
write-output 'Scripts repo exists resetting to origin'
$cwd = $pwd
cd $scriptsDirectory
git clean -xdf
git fetch origin
git reset --hard origin/master
cd $cwd
}
else
{
if(test-path $scriptsDirectory)
{
write-output 'Removing non git profile'
remove-item -recurse -force $scriptsDirectory
}
write-output 'Cloning powershell-scripts'
git clone $env:PowerShellScriptsRepo $scriptsDirectory
}
if(!(test-path $profile)) {
new-item $profile -Force -Type File -ErrorAction Stop > $null
}
$profileLine = @"
#powershell-scipts
`$env:PowerShellModules = 'C:\code\powershell-scripts\'
Get-ChildItem (`$env:PowerShellModules + "*.psm1") | ForEach-Object {Import-Module `$_.FullName -DisableNameChecking }
"@
if(select-string -Path $profile -Pattern 'powershell-scripts' -Quiet -SimpleMatch) {
return
}
@"
$profileLine
"@ | out-file $profile -Append -Encoding (Get-FileEncoding $profile)