Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Defining variables
- $ZabbixProxies=
- $InstallDir=
- # getting IP address
- [string]$IPAddress = [array]((Get-WmiObject -Class win32_networkadapterconfiguration | Where-Object {$_.defaultIPGateway -ne $null}).IPAddress)[0]
- # defining networks and proxies
- $ip_ranges= @(
- ("net1", "start_ip1", "end_ip1", "proxy1"),
- ("net2", "start_ip2", "end_ip2", "proxy2"),
- ("net3", "start_ip3", "end_ip3", "proxy3")
- )
- # defining Active Proxy
- ForEach ($range in $ip_ranges) {
- if (([version]$IPAddress -ge [version]$range[1]) -AND ([version]$IPAddress -le [version]$range[2])) {
- $ZabbixActiveProxy = $range[3]
- $Changed = True
- }
- }
- # changing conf
- if ($Changed){
- Write-Output "Server=$ZabbixProxies`nServerActive=$ZabbixActiveProxy | Out-File $InstallDir\zabbix_agentd.conf.d\server.conf" -Force -Encoding ASCII
- Restart-Service "Zabbix Agent"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement