diff --git a/Install-Filebeat.ps1 b/Install-Filebeat.ps1 new file mode 100644 index 0000000..cb9428b --- /dev/null +++ b/Install-Filebeat.ps1 @@ -0,0 +1,31 @@ +# PowerShell Script to Install Filebeat 8.17.4 on Windows + +# Variables +$filebeatUrl = "https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.17.4-windows-x86_64.zip" +$zipPath = "$env:TEMP\filebeat.zip" +$extractPath = "C:\Program Files" +$finalPath = "C:\Program Files\Filebeat" +$originalDir = "$extractPath\filebeat-8.17.4-windows-x86_64" + +Write-Host "Downloading Filebeat..." -ForegroundColor Cyan +Invoke-WebRequest -Uri $filebeatUrl -OutFile $zipPath + +Write-Host "Extracting Filebeat to $extractPath..." -ForegroundColor Cyan +Expand-Archive -Path $zipPath -DestinationPath $extractPath -Force + +Write-Host "Renaming extracted folder to 'Filebeat'..." -ForegroundColor Cyan +Rename-Item -Path $originalDir -NewName "Filebeat" + +# Set execution policy for the current process if needed +$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 as a Windows service +Write-Host "Installing Filebeat service..." -ForegroundColor Cyan +Set-Location -Path $finalPath +.\install-service-filebeat.ps1 + +Write-Host "Filebeat installation completed!" -ForegroundColor Green