Zabbix Agent Installation (Intune) - RoBeDi/PowerShell GitHub Wiki
Overview
This PowerShell script automates the installation and configuration of the Zabbix Agent on Intune-enrolled Windows machines. It ensures that the correct version of the Zabbix Agent is downloaded, installed, and configured based on your environment's requirements. The script also manages the Zabbix service, updating configuration files and handling various parameters necessary for agent-server communication.
Script: Install-ZabbixAgent-Intune.ps1
Prerequisites
Before using this script, the following preparations and considerations must be made:
- Access to the Zabbix Server: Ensure that you have access to the Zabbix Server or Zabbix Proxy. You will need their IP addresses to configure the communication correctly.
- Location of Script and Configuration Files: You must know where your PowerShell script and configuration files are located within your network.
- Administrator Privileges: Ensure that you have administrator rights on the machine where you will run the script.
Updating the Zabbix Agent Version
In the script, the $version
variable defines the version of the Zabbix Agent that will be downloaded and installed. This variable needs to be updated whenever a new version of the Zabbix Agent is released.
Instruction:
-
Locate the
$version
variable: In the script, find the line where$version
is defined. The current value might look like this:$version = "7.0.4"
-
Update the version: Replace the existing value with the new version number that Zabbix has published. You can find the latest version on the official Zabbix website or download page.
-
Example: If the new version is
7.0.5
, modify the line as follows:$version = "7.0.5"
By ensuring that the $version
variable is updated with each new release, the script will always install the latest stable version of the Zabbix Agent. This ensures compatibility with the Zabbix server and helps maintain security and performance improvements provided by the updates.
Remember to test the script in a non-production environment after any version changes to confirm the installation process functions correctly with the new Zabbix Agent version.
Modifications Required Before Use
Certain parts of the script need to be customized to reflect your organization's environment:
\\FQDN\SHARE
1. This is the location where the PowerShell script and the Zabbix Agent configuration file are stored. You must replace this placeholder with the actual file path accessible by the system running the script. This is required in sections where the script accesses template files (e.g., template_zabbix_agentd.conf
) and other shared resources.
- Example: Replace
\\FQDN\SHARE
with your file share, such as\\server.mycompany.local\deployment
.
[Zabbix_Server_IP]
2. This refers to the IP address of the Zabbix server responsible for receiving data from the agent. You need to replace this with the actual IP address of your Zabbix server.
- Example: Replace
[Zabbix_Server_IP]
with the actual IP, such as192.168.0.10
.
[Zabbix_Proxy_Server_IP]
3. If your infrastructure uses a Zabbix Proxy, you will need to provide the IP address of this proxy. The script makes different configurations based on network subnets, assigning machines to either the Zabbix Server or the Proxy.
- Example: Replace
[Zabbix_Proxy_Server_IP]
with the actual IP address of the Zabbix Proxy, such as192.168.0.11
.
10.145
and 10.30
4. Subnets: The script dynamically configures the Zabbix agent based on the subnet the machine is connected to. Machines in different subnets are automatically assigned to either the Zabbix server or a Zabbix proxy.
10.145
: Machines in this subnet will be assigned to the Zabbix proxy.10.30
: Machines in this subnet will be assigned to the Zabbix server.
If your network has different subnets, modify these values to reflect your actual network configuration.
Windows clients
and Windows servers
5. Host Metadata: The Zabbix HostMetaData
parameter is used for automatic host registration in the Zabbix server. The script uses different metadata depending on whether the machine is assigned to the Zabbix server or a Zabbix proxy.
Windows clients
: This metadata is applied to client machines.Windows servers
: This metadata is applied to server machines.
Modify these values as needed to match the metadata used in your Zabbix autoregistration process.
Key Functionalities of the Script
-
Stop and Start Zabbix Agent Service:
- The script contains functions (
Stop-ZabbixAgentService
andStart-ZabbixAgentService
) to stop the Zabbix service before configuration and start it once the installation and configuration processes are completed.
- The script contains functions (
-
Install Zabbix Agent:
- The script automatically downloads the appropriate version of the Zabbix agent (32-bit or 64-bit) based on the machine's architecture. It installs the agent with predefined parameters such as
Server
,ServerActive
, andHostName
.
- The script automatically downloads the appropriate version of the Zabbix agent (32-bit or 64-bit) based on the machine's architecture. It installs the agent with predefined parameters such as
-
Update Zabbix Configuration:
- After installation, the script updates the Zabbix configuration file with the correct
Server
,ServerActive
, andHostMetaData
values based on the machine's subnet and role.
- After installation, the script updates the Zabbix configuration file with the correct
-
Copy Template Configuration:
- The script connects to the shared drive specified by
\\FQDN\SHARE
, retrieves the template configuration file, and copies it to the local machine's Zabbix configuration folder.
- The script connects to the shared drive specified by
-
Service Management:
- The script ensures that the Zabbix agent service is stopped during configuration and restarts it once the installation and updates are completed.
How to Run the Script
-
Download the Script: Make sure the script is saved in an accessible location in your network.
-
Modify the Script: As mentioned above, replace the placeholders (
[Zabbix_Server_IP]
,[Zabbix_Proxy_Server_IP]
, etc.) with actual values corresponding to your environment. -
Execute the Script: Run the script with administrator privileges. For example, you can invoke the script like this:
Powershell -ExecutionPolicy ByPass -File "\\server.mycompany.local\deployment\Install-ZabbixAgent-Intune.ps1"
-
Monitor Output: The script will output status messages to the console, informing you of the steps being executed. Watch for any errors or warnings, and ensure all configurations are applied as expected.
Additional Notes
- The script dynamically configures settings based on system architecture and network configurations. Ensure that you review the default settings and adjust them according to your specific needs.
- Always test the script in a non-production environment before deploying it broadly across your organization.
By following these steps and modifying the script as necessary, you can automate the installation and configuration of the Zabbix Agent on Windows machines in your network.