Skip to content

Instantly share code, notes, and snippets.

@ryanrousseau
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanrousseau/938f11a760dfbbc76c51 to your computer and use it in GitHub Desktop.
Save ryanrousseau/938f11a760dfbbc76c51 to your computer and use it in GitHub Desktop.
Write-Output "Checking ChocolateyInstall env variable"
$chocolateyInstall = [Environment]::GetEnvironmentVariable("ChocolateyInstall")
if (!$chocolateyInstall) {
Write-Output "ChocolateyInstall env variable does not exist, using $ChocolateyInstallDir"
$chocolateyInstall = $ChocolateyInstallDir
[Environment]::SetEnvironmentVariable("ChocolateyInstall", $chocolateyInstall)
[Environment]::SetEnvironmentVariable("ChocolateyInstall", $chocolateyInstall, "Machine")
}
Write-Output "Ensuring the Chocolatey package manager is installed..."
$chocolateyBin = "$chocolateyInstall\bin"
$chocInstalled = Test-Path "$chocolateyBin\cinst.exe"
if (-not $chocInstalled) {
Write-Output "Chocolatey not found, installing..."
$installPs1 = ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
Invoke-Expression $installPs1
& cmd.exe /C "SET PATH=%PATH%;$chocolateyBin"
Write-Output "Chocolatey installation complete."
} else {
Write-Output "Chocolatey was found at $chocolateyBin and won't be reinstalled."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment