############################################ #Author: lixiaosong#[email protected] #For: Auto install zabbix-agent#version:1.0############################################# #wget http:// Www.zabbix.com/downloads/2.4.1/zabbix_agents_2.4.1.win.zip -outfile c:\zabbix_agent.zipfunction unzip-file () { param ([string] $ZipFile, [string] $TargetFolder) #确保目标文件夹必须存在 if (!) ( test-path $TargetFolder)) { mkdir $TargetFolder } $shellApp = new-object - comobject shell.application $files = $shellApp. NameSpace ($ZipFile). Items () $shellApp. NameSpace ($TargetFolder). CopyHere ($files)} #将安装文件解压Unzip-file -zipfile c:\zabbix_agent.zip -targetfolder c:\zabbix_ agent# Deleting the default profile Rm c:\zabbix_agent\conf\zabbix_agentd.win.conf$hostname=hostnameadd-content -value "LogFile=C:\zabbix_agent\ Zabbix.log " C:\zabbix_agent\conf\zabbix_agentd.win.confAdd-Content -value " server=1.1.1.1 " C:\zabbix_agent\conf\zabbix_agentd.win.confAdd-Content -value " Hostname= $hostname " c:\ zabbix_agent\conf\zabbix_agentd.win.confadd-content -value "ServerActive=1.1.1.1" C:\ zabbix_agent\conf\zabbix_agentd.win.conf #判断系统类型 $sysinfo = (systeminfo.exe) [+] $sysinfonew = $sysinfo. Replace ("System type: ", "") if ($sysinfonew -like "X64-BASED PC" ) {c:\zabbix_agent\bin\win64\zabbix_agentd.exe -c c:\zabbix_agent\conf\ Zabbix_agentd.win.conf -i}else {c:\zabbix_agent\bin\win32\zabbix_agentd.exe -c c:\zabbix_ agent\conf\zabbix_agentd.win.conf -i}start-service "Zabbix agent" Rm C:\zabbix_agent.zip
This article is from the "operation and maintenance of life" blog, please make sure to keep this source http://lixiaosong.blog.51cto.com/705126/1663595
Powershell Automated Installation Zabbix Agent