-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmethods.ps1
More file actions
61 lines (34 loc) · 1.55 KB
/
methods.ps1
File metadata and controls
61 lines (34 loc) · 1.55 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
function Install-Chocolatey {
$chocoPath = "$env:ProgramData\Chocolatey"
$chocoInstall = Test-Path $chocoPath
if ($chocoInstall -eq $false) {
Write-Host "`n Chocolatey is not installed. Installing Chocolatey..."
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'))
}
else {
Write-Host "`n Chocolatey is already installed." -ForegroundColor Yellow
}
}
function Install-Applications {
param (
[Parameter(Mandatory=$true)]
[string[]]$sections
)
$config = Get-Content -Path "$PSScriptRoot\config.json" | ConvertFrom-Json
$pakages = $config.packages
Write-Host "`n Installing Chocolatey packages..." -ForegroundColor Green
Write-Host "`n To install packages, you need to use the 'install' option in config.json. Set it to true or false." -ForegroundColor Magenta
foreach ($section in $sections.GetEnumerator()) {
$app = $pakages.$section
if($true -in $app.install) {
$app | Where-Object {$_.install -eq $true} | ForEach-Object {
Write-Host "`n Installing $($_.name)" -ForegroundColor Green
choco install $_.package -y
}
}
else {
Write-Host "`n No app selected in section: $section." -ForegroundColor Yellow
}
}
Write-Host "`r"
}