-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-apps.ps1
45 lines (37 loc) · 1.11 KB
/
install-apps.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
#Requires -RunAsAdministrator
$PACKAGES_PATH = "$PSScriptRoot\packages.csv"
function Load-Packages () {
if (Test-Path $PACKAGES_PATH) {
$script:packages = Get-Content $PACKAGES_PATH | ConvertFrom-Csv |
Select-Object packagename,params,flags
}
else {
Write-Error "Package csv doesn't exist, this is a fatal error!"
exit 1
}
}
function Install-Choco-Package ($package) {
choco install -y $package.packagename -params $package.params --allowEmptyChecksums --limit-output $package.flags
Run-Script-Package $package
}
function Run-Script-Package ($package) {
$scriptPath = "$PSScriptRoot\post-install-scripts\$($package.packagename).ps1"
if (Test-Path $scriptPath) {
Write-Host "Running: $scriptPath"
.$scriptPath
}
}
Load-Packages
# update setup files
Push-Location $PSScriptRoot
git pull
$gitExitCode = $LASTEXITCODE
Pop-Location
if ($gitExitCode -ne 0) {
Save-State
Write-Error "Git encountered an error, please resolve before updating again."
exit 1
}
foreach ($package in $script:packages) {
Install-Choco-Package $package
}