Created
March 2, 2023 21:38
-
-
Save JSONOrona/13a73acc286c80ee46c1a08a090f5809 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$workstation_version = "21.11.416" | |
$install_path = "C:\opscode\chef-workstation" | |
if (Test-Path $install_path) { | |
$existing_version = (Get-Command "chef" -ErrorAction SilentlyContinue).FileVersionInfo.ProductVersion | |
if ($existing_version -eq $workstation_version) { | |
Write-Host "Chef Workstation $workstation_version is already installed." | |
return | |
} else { | |
Write-Host "An older version of Chef Workstation ($existing_version) is installed. Upgrading to version $workstation_version." | |
} | |
} else { | |
Write-Host "Chef Workstation is not installed. Installing version $workstation_version." | |
} | |
$installer_path = "https://packages.chef.io/files/stable/chef-workstation/$workstation_version/windows/2019/chef-workstation-$workstation_version-1-x64.msi" | |
$install_args = @( | |
"/qn", | |
"/norestart", | |
"/L*v", | |
"C:\chef-workstation-install.log", | |
"ADDLOCAL=WorkstationFeature,WorkstationV2Feature", | |
"INSTALLDIR=$install_path", | |
"PATH_ADDITIONS=$install_path\bin", | |
"CHEF_WORKSTATION_VERSION=$workstation_version" | |
) | |
Invoke-WebRequest $installer_path -OutFile "$env:TEMP\chef-workstation.msi" | |
Start-Process msiexec.exe -Wait -ArgumentList "/i $env:TEMP\chef-workstation.msi $($install_args -join ' ')" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment