# Script to install zabbix agent. # Technolog Networks, 2024-07-27 # iRaven Start-Transcript -Path "c:\irnh\Install-ZabbixAgent.log" -Append $InstallFolder = "C:\Program Files\Zabbix Agent" $InstallerLog = "C:\irnh\Installer-ZabbixAgent.log" $SoftwareDeployLocation = "\\technolog.net\sysvol\technolog.net\SoftwareDeploy\zabbix_agent-7.0.9-windows-amd64-openssl.msi" $SDZabbixVersion = "7.0.9" $ZabbixVersionInstalled = (Get-WmiObject -Class Win32_Product | where name -like "Zabbix*" | select Name, Version).Version # Zabbix settings $ZabbixServer = "10.10.0.90" $ZabbixAgentLogFile = "$InstallFolder\zabbix_agentd.log" Function CheckZabbixInstall { if ($ZabbixVersionInstalled -ne $null) { if ($ZabbixVersionInstalled -like "$SDZabbixVersion*") { return $true } else { return $false } } else { return $false } } if ((CheckZabbixInstall) -eq $true){ Write-Host "Zabbix is currently up-to-date on this computer with the version stored in domain SYSVOL. No action is needed." } else { Write-Host "An upgrade to Zabbix was detected in domain SYSVOL." Write-Host "This computer has $ZabbixVersionInstalled installed. Upgrading to the newest version $SDZabbixVersion." try { msiexec /log "$InstallerLog" /i "$SoftwareDeployLocation" SERVER="$ZabbixServer" HOSTNAME=$env:COMPUTERNAME ENABLEPATH=1 /quiet } catch { Write-Error "Zabbix Agent could not be installed." } } Stop-Transcript