diff options
author | Sean Simmons <ssimmons@progress.com> | 2022-11-04 15:30:10 -0400 |
---|---|---|
committer | Sean Simmons <ssimmons@progress.com> | 2022-11-04 15:30:10 -0400 |
commit | 0115076da1cc68f44bf86d693aca1cbff3a6223c (patch) | |
tree | 453426f5b823817496d88723d7ad6c6cdd967aef | |
parent | 0bd9b138adaa4abb7fa4dff00daf558f5d882bf4 (diff) | |
download | chef-0115076da1cc68f44bf86d693aca1cbff3a6223c.tar.gz |
adding choco function
idea here is not to install it if it already exists.
-rw-r--r-- | omnibus/omnibus-test.ps1 | 25 |
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 |