Skip to content

Instantly share code, notes, and snippets.

@NickMRamirez
Created June 28, 2015 18:46
Show Gist options
  • Save NickMRamirez/49937148c8f47b27dd0b to your computer and use it in GitHub Desktop.
Save NickMRamirez/49937148c8f47b27dd0b to your computer and use it in GitHub Desktop.
Download and install Chef-client on Windows
$chef_client_url = "https://opscode-omnibus-packages.s3.amazonaws.com/windows/2008r2/x86_64/chef-client-12.3.0-1.msi"
$web_client = New-Object System.Net.WebClient
$target_file = "C:\\chef-client-12.3.0-1.msi"
Write-Host "Checkig if Chef-client is installed..."
$chef_client_object = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object { $_.DisplayName -like "Chef*" }
if ($chef_client_object -eq $NULL)
{
Write-Host "Chef-client not installed"
Write-Host "Checking if Chef-client installer exists..."
$installer_exists = Test-Path $target_file
if ($installer_exists -eq $TRUE)
{
Write-Host "Installer already exists, skipping download"
}
else
{
Write-Host "Downloading Chef-client installer..."
$web_client.DownloadFile($chef_client_url, $target_file)
Write-Host "Finished downloading."
}
Write-Host "Running Chef-client installer..."
Start-Process -file $target_file -passthru | wait-process
Write-Host "Finished installing"
}
else
{
Write-Host "Chef-client already installed, skipping installation"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment