$ErrorActionPreference = 'Stop'
$Url = 'https://repository.eset.com/v1/com/eset/apps/business/eei/agent/v2/2.6.5058.0/ei_connector_nt64.msi'
$Dir = Join-Path $env:TEMP 'ESET-Inspect-Connector'
$Msi = Join-Path $Dir 'ei_connector_nt64.msi'
$Log = Join-Path $Dir 'ESET-Inspect-Connector-install.log'
New-Item -Path $Dir -ItemType Directory -Force | Out-Null
try {
Write-Host 'Pobieranie ESET Inspect Connector...' -ForegroundColor Cyan
Invoke-WebRequest -Uri $Url -OutFile $Msi
$Signature = Get-AuthenticodeSignature -FilePath $Msi
if ($Signature.Status -ne 'Valid' -or $Signature.SignerCertificate.Subject -notmatch 'ESET') {
throw "Nieprawidłowy podpis MSI: $($Signature.Status) | $($Signature.SignerCertificate.Subject)"
}
Write-Host "Podpis poprawny: $($Signature.SignerCertificate.Subject)" -ForegroundColor Green
Write-Host "SHA-256: $((Get-FileHash -Path $Msi -Algorithm SHA256).Hash)"
$Process = Start-Process -FilePath 'msiexec.exe' -Wait -PassThru -ArgumentList @(
'/i'
"`"$Msi`""
'/qn'
'/norestart'
'/l*v'
"`"$Log`""
)
if ($Process.ExitCode -in 0, 3010) {
Write-Host "ESET Inspect Connector zainstalowany. Kod MSI: $($Process.ExitCode)" -ForegroundColor Green
Write-Host "Log instalacji: $Log"
}
else {
throw "Błąd instalacji MSI. Kod: $($Process.ExitCode). Log: $Log"
}
}
catch {
Write-Error $_.Exception.Message
Write-Host "MSI i log pozostają w: $Dir" -ForegroundColor Yellow
}