Skip to content

Instantly share code, notes, and snippets.

@DMeurer
Created October 24, 2024 10:20
Show Gist options
  • Save DMeurer/3b807e98c6ba87ac0bd074b7e7953023 to your computer and use it in GitHub Desktop.
Save DMeurer/3b807e98c6ba87ac0bd074b7e7953023 to your computer and use it in GitHub Desktop.
Install a chocolately package and chocolately if not already installed. You have to run `Set-ExecutionPolicy remotesigned` to execute the script.
# install Chocolately
If(Test-Path -Path "$env:ProgramData\Chocolatey") {
echo "Chocolately is installed"
} Else {
echo "Chocolately is not installed. Installing now..."
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
echo "Chocolately is installed"
}
# reload path
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
# install stuff
$Packages = 'eclipse', 'git'
ForEach ($PackageName in $Packages)
{
choco install $PackageName -y
}
# reload path again
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment