Deployment_scripts/Install-Filebeat-MSI.ps1

37 lines
1.5 KiB
PowerShell

# PowerShell Script to Install Filebeat 8.17.0 via MSI
# Variables
$msiUrl = "https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.17.0-windows-x86_64.msi"
$msiPath = "$env:TEMP\filebeat-8.17.0.msi"
$installPath = "C:\Program Files\Elastic\Beats\8.17.0\filebeat"
$installLog = "$env:TEMP\filebeat_install.log"
Write-Host "Downloading Filebeat MSI..." -ForegroundColor Cyan
Invoke-WebRequest -Uri $msiUrl -OutFile $msiPath
Write-Host "Installing Filebeat using MSI..." -ForegroundColor Cyan
Start-Process msiexec.exe -ArgumentList "/i `"$msiPath`" /qn /norestart /log `"$installLog`"" -Wait
# Verify installation path
if (Test-Path $installPath) {
Write-Host "Filebeat installed to $installPath" -ForegroundColor Green
# Set Execution Policy temporarily
$policy = Get-ExecutionPolicy -Scope Process
if ($policy -ne 'Unrestricted') {
Write-Host "Setting execution policy to Unrestricted for this session..." -ForegroundColor Yellow
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Force
}
# Install Filebeat service
Write-Host "Installing Filebeat as a Windows service..." -ForegroundColor Cyan
Push-Location $installPath
.\install-service-filebeat.ps1
Pop-Location
Write-Host "Filebeat service installed successfully!" -ForegroundColor Green
} else {
Write-Host "Filebeat was not found in the expected location: $installPath" -ForegroundColor Red
Write-Host "Check the installation log at $installLog for more information." -ForegroundColor Yellow
}