# Vérifie si Chocolatey est installé, sinon l'installe
if (!(Get-Command choco.exe -ErrorAction SilentlyContinue)) {
Write-Host "Installation de Chocolatey..." -ForegroundColor Yellow
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Write-Host "Chocolatey installé !" -ForegroundColor Green
}
# Liste des logiciels à installer
$packages = @(
@{name="7zip.install"; special=$false},
@{name="adobereader"; special=$false},
@{name="vlc"; special=$false},
@{name="firefox"; special=$false},
@{name="everything"; special=$false},
@{name="paint.net"; special=$false},
@{name="googlechrome"; special=$true}, # Besoin d'options spéciales
@{name="notepadplusplus"; special=$false},
@{name="dotnet-8.0-desktopruntime"; special=$false}
)
# Compteurs de résultats
$successCount = 0
$failCount = 0
$alreadyInstalled = 0
Write-Host "`n=== DÉBUT DES INSTALLATIONS ===" -ForegroundColor Cyan
# Installation de chaque logiciel avec gestion d'erreurs
foreach ($pkg in $packages) {
Write-Host "`n📦 Installation de $($pkg.name)..." -ForegroundColor Yellow
try {
# Commande selon si c'est Chrome (options spéciales)
if ($pkg.special) {
& choco install $pkg.name --ignore-checksums --force -y 2>&1 | ForEach-Object { Write-Host $_ -ForegroundColor Gray }
} else {
& choco install $pkg.name -y 2>&1 | ForEach-Object { Write-Host $_ -ForegroundColor Gray }
}
# Vérification du code de retour (essentiel avec Chocolatey)
if ($LASTEXITCODE -eq 0) {
Write-Host "✅ $($pkg.name) installé avec succès !" -ForegroundColor Green
$successCount++
} elseif ($LASTEXITCODE -eq 1605) {
Write-Host "ℹ️ $($pkg.name) déjà installé (code 1605)" -ForegroundColor Cyan
$alreadyInstalled++
} else {
Write-Warning "❌ ÉCHEC $($pkg.name) - Code d'erreur: $LASTEXITCODE"
$failCount++
}
}
catch {
Write-Error "💥 ERREUR critique pour $($pkg.name) : $($_.Exception.Message)"
$failCount++
}
}
# Résumé final
Write-Host "`n=== RÉSUMÉ FINAL ===" -ForegroundColor Cyan
Write-Host "✅ Succès: $successCount" -ForegroundColor Green
Write-Host "ℹ️ Déjà installé: $alreadyInstalled" -ForegroundColor Cyan
Write-Host "❌ Échecs: $failCount" -ForegroundColor Red
if ($failCount -eq 0) {
Write-Host "🎉 Toutes les installations réussies !" -ForegroundColor Green
} else {
Write-Host "⚠️ $failCount installation(s) ont échoué. Vérifiez les logs ci-dessus." -ForegroundColor Yellow
}