@@ -5,6 +5,9 @@ Write-Output "Verbose logging enabled: $VerbosePreference"
55# Define packages that need checksum bypass (temporary workaround)
66$ignoreChecksumPackages = @ (' sysinternals' , ' network-miner' )
77
8+ # Define packages that may require reboot (exit code 3010 is success but needs reboot)
9+ $rebootExpectedPackages = @ (' vagrant' , ' virtualbox' , ' vmware-workstation-player' )
10+
811# Function to install packages with error handling
912function Install-ChocoPackages {
1013 param (
@@ -21,26 +24,40 @@ function Install-ChocoPackages {
2124 Write-Host " Installing $package ..." - ForegroundColor Cyan
2225
2326 # Check if package needs checksum bypass
24- $installCommand = " choco install $package --yes --no-progress --acceptlicense --limitoutput"
27+ $installArgs = " --yes --no-progress --acceptlicense --limitoutput"
2528 if ($ignoreChecksumPackages -contains $package ) {
26- $installCommand += " --ignore-checksums"
29+ $installArgs += " --ignore-checksums"
2730 Write-Host " WARNING: Installing $package with checksums ignored" - ForegroundColor Yellow
2831 }
2932
3033 # Execute installation
31- Invoke-Expression $installCommand
32- if ($LASTEXITCODE -ne 0 ) {
33- throw " Chocolatey installation failed for $package (Exit code: $LASTEXITCODE )"
34+ choco install $package $installArgs
35+ $exitCode = $LASTEXITCODE
36+
37+ # Handle expected reboot requirements
38+ if ($rebootExpectedPackages -contains $package -and $exitCode -eq 3010 ) {
39+ Write-Host " SUCCESS: $package installed but requires reboot (Exit code: 3010)" - ForegroundColor Yellow
40+ $global :rebootRequired = $true
41+ }
42+ # Handle standard success
43+ elseif ($exitCode -eq 0 ) {
44+ Write-Host " $package installed successfully" - ForegroundColor Green
45+ }
46+ # Handle failure
47+ else {
48+ throw " Chocolatey installation failed for $package (Exit code: $exitCode )"
3449 }
35- Write-Host " $package installed successfully" - ForegroundColor Green
3650 }
3751 catch {
3852 Write-Host " ERROR: $_ " - ForegroundColor Red
39- exit $LASTEXITCODE
53+ exit $exitCode
4054 }
4155 }
4256}
4357
58+ # Initialize reboot flag
59+ $global :rebootRequired = $false
60+
4461# Upgrade Chocolatey first
4562try {
4663 Write-Host " Upgrading Chocolatey..." - ForegroundColor Magenta
@@ -109,12 +126,22 @@ try {
109126 if ($LASTEXITCODE -ne 0 ) {
110127 Write-Host " Package listing completed with warnings" - ForegroundColor Yellow
111128 Write-Host " Full package list:"
112- choco list
129+ choco list -- local - only
113130 }
114131}
115132catch {
116133 Write-Host " Package listing failed: $ ( $_.Exception.Message ) " - ForegroundColor Red
117134}
118135
136+ # Handle reboot notification
137+ if ($global :rebootRequired ) {
138+ Write-Host " `n WARNING: Some packages require a system reboot to function properly!" - ForegroundColor Yellow
139+ Write-Host " Packages requiring reboot: $ ( $rebootExpectedPackages -join ' , ' ) " - ForegroundColor Yellow
140+ Write-Host " CI environment note: Automatic reboot not performed. Manual reboot may be required." - ForegroundColor Yellow
141+ }
142+ else {
143+ Write-Host " `n All packages installed successfully without reboot requirements!" - ForegroundColor Green
144+ }
145+
119146Write-Host " `n Chocolatey installation completed!" - ForegroundColor Green
120147exit 0
0 commit comments