summaryrefslogtreecommitdiff
path: root/omnibus
diff options
context:
space:
mode:
authorSean Simmons <ssimmons@progress.com>2022-11-04 15:30:10 -0400
committerSean Simmons <ssimmons@progress.com>2022-11-04 15:30:10 -0400
commit0115076da1cc68f44bf86d693aca1cbff3a6223c (patch)
tree453426f5b823817496d88723d7ad6c6cdd967aef /omnibus
parent0bd9b138adaa4abb7fa4dff00daf558f5d882bf4 (diff)
downloadchef-0115076da1cc68f44bf86d693aca1cbff3a6223c.tar.gz
adding choco function
idea here is not to install it if it already exists.
Diffstat (limited to 'omnibus')
-rw-r--r--omnibus/omnibus-test.ps125
1 files changed, 22 insertions, 3 deletions
diff --git a/omnibus/omnibus-test.ps1 b/omnibus/omnibus-test.ps1
index 2c4331ff2f..906b403c9a 100644
--- a/omnibus/omnibus-test.ps1
+++ b/omnibus/omnibus-test.ps1
@@ -2,9 +2,28 @@
$ErrorActionPreference = "Stop"
# install chocolatey
-Set-ExecutionPolicy Bypass -Scope Process -Force
-[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
-iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
+function installChoco {
+
+ if (!(Test-Path "$($env:ProgramData)\chocolatey\choco.exe")) {
+ Write-Output "Chocolatey is not installed, proceeding to install"
+ try {
+ write-output "installing in 3..2..1.."
+ Set-ExecutionPolicy Bypass -Scope Process -Force
+ [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
+ iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
+ }
+
+ catch {
+ Write-Error $_.Exception.Message
+ }
+ }
+
+ else {
+ Write-Output "Chocolatey is already installed"
+ }
+}
+
+installChoco
# install powershell core
Invoke-WebRequest "https://github.com/PowerShell/PowerShell/releases/download/v7.0.3/PowerShell-7.0.3-win-x64.msi" -UseBasicParsing -OutFile powershell.msi