Chocolatey
Chocolatey ist ein Windows-Paketmanager, der die Softwareinstallation, Updates und Konfiguration automatisiert. Verwalte Pakete direkt von PowerShell oder Command Prompt aus.
Installation
Chocolatey Bootstrap
# Run PowerShell as Administrator, then:
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'))
# Verify installation
choco --version
Windows Package Manager als Alternative
winget install Chocolatey.Chocolatey
Grundbefehle
| Befehl | Beschreibung |
|---|---|
choco --version | Chocolatey-Version anzeigen |
choco --help | Allgemeine Hilfe anzeigen |
choco help <command> | Hilfe für spezifischen Befehl |
choco list | Alle installierten Pakete auflisten |
choco search <package> | Nach Paket suchen |
choco install <package> | Paket installieren |
choco upgrade <package> | Paket aktualisieren |
choco uninstall <package> | Paket deinstallieren |
Installationsbefehle
# Install single package
choco install notepadplusplus
# Install multiple packages
choco install git nodejs python
# Install with version
choco install git --version=2.35.1
# Install without confirmation
choco install git -y
# Install to specific directory
choco install git --install-arguments="'INSTALLDIR=C:\Git'"
# Install with parameters
choco install nodejs --params="'/InstallDirectory:C:\nodejs'"
# Install from local package
choco install ./localpackage.nupkg
# Install from custom source
choco install package -s https://custom-feed.com
Suche und Entdeckung
# Search for packages
choco search docker
# Search with detailed info
choco search nodejs --verbose
# List all packages in remote repository
choco list --page=0 --page-size=50
# Search local packages only
choco list --local-only
# Search with approved-only flag
choco search vim --approve-only
Paketverwaltung
# List installed packages
choco list
# List installed with version
choco list --local-only
# List outdated packages
choco outdated
# Get info about specific package
choco info python
# Show package dependencies
choco depends git
# Pin package (prevent upgrades)
choco pin add -n git
# Unpin package
choco pin remove -n git
Upgrade-Operationen
# Upgrade single package
choco upgrade git
# Upgrade multiple packages
choco upgrade nodejs python ruby
# Upgrade all packages
choco upgrade all
# Upgrade without confirmation
choco upgrade all -y
# Upgrade to specific version
choco upgrade git --version=2.35.1
# Upgrade with parameters
choco upgrade nodejs --params="'/SILENT'"
# Upgrade excluding specific packages
choco upgrade all --except="git,nodejs"
Deinstallation und Bereinigung
# Uninstall single package
choco uninstall notepadplusplus
# Uninstall multiple packages
choco uninstall git nodejs -y
# Uninstall with dependencies
choco uninstall packagename --remove-dependencies
# Uninstall forcing even if errors
choco uninstall git -f -y
# Remove package cache
choco cache list
# Clear all cache
rm $env:ChocolateyInstall\cache\*.nupkg
Konfiguration
# Show configuration
choco config list
# Set configuration value
choco config set cacheLocation D:\ChocolateyCache
# Set proxy
choco config set proxyLocation http://proxy.company.com:8080
# Set proxy user
choco config set proxyUser username
# Set default confirmation
choco config set confirmAll true
# Allow global confirmation
choco feature enable -n useRememberedArgumentsForUpgrades
Quellenverwaltung
# List sources
choco source list
# Add source
choco source add -n=custom -s=https://my-nuget-feed.com
# Remove source
choco source remove -n=custom
# Disable source
choco source disable -n=custom
# Enable source
choco source enable -n=custom
# Set priority (order matters for resolution)
choco source list --verbose
Erweiterte Funktionen
Funktionsverwaltung
# List features
choco feature list
# Enable feature
choco feature enable -n=caskNuget
# Disable feature
choco feature disable -n=caskNuget
# Common features
choco feature list # Shows: exitOnRebootDetected, autoUninstaller, etc.
Pakete exportieren und importieren
# Export installed packages
choco export packages.config
# Get package list as command
choco list | Select-Object -Property Name > packages.txt
# Convert list to install command
Get-Content packages.txt | ForEach-Object { "choco install $_ -y" }
# Create packages.config and import
# Manually create packages.config, then:
choco install packages.config -y
Batch-Verarbeitung
# Install all packages from file
$packages = @("git", "nodejs", "python", "vscode", "7zip")
foreach ($package in $packages) {
choco install $package -y
}
# Upgrade all with filter
choco upgrade all -y --except="dotnet-core,java"
# Uninstall with filter
Get-Item "$env:ProgramFiles\*" |
Where-Object { $_.Name -match "OldApp" } |
ForEach-Object { choco uninstall $_.Name -y }
Häufige Paketbeispiele
# Developer Tools
choco install git nodejs python vscode visualstudio2022community
# Utilities
choco install 7zip winrar notepadplusplus vlc
# Browsers
choco install googlechrome firefox edge
# Communication
choco install discord slack
# Media
choco install ffmpeg imagemagick
# Virtual Machines
choco install virtualbox docker-desktop
# System Tools
choco install sysinternals ccleaner everything
# Languages
choco install golang rust ruby php
Scripting-Beispiele
PowerShell-Skript zur Installation der Entwicklungsumgebung
# dev-setup.ps1
param(
[switch]$SkipConfirm
)
$packages = @(
"git",
"nodejs",
"python",
"vscode",
"docker-desktop",
"postman",
"dbeaver",
"mingw"
)
Write-Host "Installing development packages..."
if ($SkipConfirm) {
foreach ($package in $packages) {
choco install $package -y
}
} else {
foreach ($package in $packages) {
choco install $package
}
}
Write-Host "Development environment setup complete!"
Geplantes Update-Skript
# update-packages.ps1 (Run via Task Scheduler)
$logFile = "C:\Logs\choco-update.log"
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
Add-Content -Path $logFile -Value "$timestamp - Starting package update"
try {
choco upgrade all -y --limit-output
Add-Content -Path $logFile -Value "$timestamp - Update successful"
} catch {
Add-Content -Path $logFile -Value "$timestamp - Update failed: $_"
}
Fehlerbehebung
Beschädigte Cache löschen
# Stop all choco processes
Stop-Process -Name "chocolatey*" -Force
# Clear cache directory
Remove-Item "$env:ChocolateyInstall\cache\*" -Force
# Reinstall problematic package
choco install packagename -f -y
Installationsprobleme beheben
# Reset Chocolatey environment
$env:ChocolateyInstall = 'C:\ProgramData\chocolatey'
$env:Path = "$env:ChocolateyInstall\bin;$env:Path"
# Fix permissions
icacls "C:\ProgramData\chocolatey" /grant:r "$env:username`:F" /t
# Verify installation
choco --version
Proxy-Probleme
# Set proxy
choco config set proxyLocation http://proxy:8080
choco config set proxyUser username
choco config set proxyPassword password
# Test connection
choco search chocolatey -s http://chocolatey.org
Best Practices
Wartungsplan
# Weekly: Check for outdated packages
choco outdated
# Monthly: Full system update
choco upgrade all -y
# Quarterly: Clean package cache
rm $env:ChocolateyInstall\cache\*.nupkg
Sicherheitsempfehlungen
- Chocolatey aktuell halten:
choco upgrade chocolatey -y - Pakete von vertrauenswürdigen Repositorys verifizieren
-f(force) Flag mit Vorsicht verwenden- Alle Pakete regelmäßig aktualisieren:
choco upgrade all - Windows Defender für Malware-Scans verwenden
Leistungsoptimierung
# Disable Windows Update during package operations
# Reduce explorer lock issues
# Use PowerShell's parallel execution for multiple packages:
@("git", "nodejs", "python") |
ForEach-Object -Parallel {
choco install $_ -y
} -ThrottleLimit 3
Integration mit CI/CD
GitHub Actions-Beispiel
name: Setup Windows Environment
jobs:
setup:
runs-on: windows-latest
steps:
- name: Install Chocolatey packages
run: |
choco install git nodejs python -y
choco upgrade all -y
Azure DevOps Pipeline
jobs:
- job: SetupEnvironment
pool:
vmImage: 'windows-latest'
steps:
- script: choco install git python nodejs -y
displayName: Install packages
Ressourcen
Last updated: 2025-03-30