-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_after_install-packages-windows.ps1.tmpl
49 lines (42 loc) · 1.97 KB
/
run_after_install-packages-windows.ps1.tmpl
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
# Self-elevate the script if required
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
$CommandLine = "-ExecutionPolicy Bypass -NoExit -File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
Start-Process -FilePath PowerShell.exe -Verb RunAs -ArgumentList $CommandLine -Wait
Exit
}
}
Function Test-CommandExists {
Param ($command)
$oldPreference = $ErrorActionPreference
$ErrorActionPreference = "stop"
try {
if (Get-Command $command) {
return $true
}
}
Catch {
return $false
}
Finally {
$ErrorActionPreference = $oldPreference
}
}
# Install Chocolatey if it is not already installed
if (-Not (Test-CommandExists "choco")) {
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString("https://community.chocolatey.org/install.ps1"))
}
Write-Host "Installing Chocolatey packages..."
choco upgrade chocolatey
Write-Host "Installing packages always used"
choco upgrade git.install --params "/GitOnlyOnPath /NoAutoCrlf /WindowsTerminal /NoShellIntegration /NoOpenSSH /Editor:VIM"
choco upgrade vim --params "/NoDesktopShortcuts /NoContextmenu /NoDefaultVimrc"
choco upgrade openssh powertoys powershell-core 1password microsoft-windows-terminal
Write-Host "Installing graphical applications"
{{- if eq .toolchains.rust true }}
[System.Environment]::SetEnvironmentVariable("RUSTUP_HOME", $HOME + "\.local\rustup",[System.EnvironmentVariableTarget]::User)
[System.Environment]::SetEnvironmentVariable("CARGO_HOME", $HOME + "\.local\cargo",[System.EnvironmentVariableTarget]::User)
choco upgrade rustup.install
{{- end }}