diff options
author | John McCrae <john.mccrae@progress.com> | 2022-11-08 11:55:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-08 11:55:20 +0000 |
commit | b5ead825d27098821ec09a00558d529690593cb1 (patch) | |
tree | 49ce0c79a0c0faecae8b590dba2e1a61f3613816 | |
parent | 0bd9b138adaa4abb7fa4dff00daf558f5d882bf4 (diff) | |
parent | 2b0d4b1cf69494b69c0790421b2d0b50e67ef73c (diff) | |
download | chef-b5ead825d27098821ec09a00558d529690593cb1.tar.gz |
Merge pull request #13330 from chef/seansimmons/powershellUpdate
-rw-r--r-- | omnibus/omnibus-test.ps1 | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/omnibus/omnibus-test.ps1 b/omnibus/omnibus-test.ps1 index 2c4331ff2f..aac620f5de 100644 --- a/omnibus/omnibus-test.ps1 +++ b/omnibus/omnibus-test.ps1 @@ -1,10 +1,29 @@ # Stop script execution when a non-terminating error occurs $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')) +# install chocolatey +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 |