@@ -257,12 +257,9 @@ install:
257257 Add-Content -Path $Path -Value "proxy: $env:HTTPS_PROXY" -Encoding utf8
258258 }
259259 Add-Content -Path $Path -Value $CustomAttrs -Encoding utf8
260- Write-Host "Configuration written successfully"
261260 }
262261
263262 if ($existingService) {
264- Write-Host "Existing service detected, performing upgrade..."
265-
266263 # Write fresh config before calling installer.ps1 — in upgrade mode
267264 # installer.ps1 preserves the existing config, so this ensures the service
268265 # starts with valid settings (including license_key) on the first start.
@@ -285,7 +282,6 @@ install:
285282 Write-Host -ForegroundColor Red "installer.ps1 not found in extracted MSI"
286283 exit 1
287284 }
288- Write-Host "Found installer.ps1 at: $($installerScript.FullName)"
289285
290286 $scriptDir = $installerScript.DirectoryName
291287 Push-Location $scriptDir
@@ -303,7 +299,6 @@ install:
303299 Pop-Location
304300 }
305301 } else {
306- Write-Host "No existing service detected, performing fresh install..."
307302 $process = Start-Process -FilePath "msiexec.exe" -ArgumentList "/qn /i `"$MSI_PATH`" GENERATE_CONFIG=true LICENSE_KEY=`"$LICENSE_KEY`" /L*v `"$env:TEMP\\msi_install.log`"" -Wait -NoNewWindow -PassThru
308303 if ($process.ExitCode -ne 0) {
309304 Write-Host -ForegroundColor Red "MSI installation failed with exit code: $($process.ExitCode)"
@@ -317,7 +312,7 @@ install:
317312 # MSI starts the service with a yamlgen-generated config (license_key only).
318313 # Rewrite config fresh and restart so all required settings take effect.
319314 Write-FreshConfig -Path $InfraConfig -LicenseKey $LICENSE_KEY -Region $NEW_RELIC_REGION -CustomAttrs $customAttributes
320- Restart-Service -Name "newrelic-infra" -Force -ErrorAction SilentlyContinue
315+ Restart-Service -Name "newrelic-infra" -Force -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
321316 }
322317 '
323318
@@ -333,14 +328,13 @@ install:
333328 if ($service.Status -ne "Running") {
334329 try {
335330 Start-Service -Name $serviceName
336- Write-Host "New Relic infrastructure agent for Windows installed and started" -ForegroundColor Green
337331 }
338332 catch {
339333 Write-Host "Error starting service: $_" -ForegroundColor Red
340334 }
341335 }
342- else {
343- Write-Host "$serviceName is already running" -ForegroundColor Green
336+ if ((Get-Service $serviceName -ErrorAction SilentlyContinue).Status -eq "Running") {
337+ Write-Host "New Relic Infrastructure Agent is running" -ForegroundColor Green
344338 }
345339 '
346340
0 commit comments