rrg92 / power-zabbix

Powershell module with lot of cmdlets that implements ZABBIX API, extra and auxiliary cmdlets
4 stars 2 forks source link

Add disable/enable with a comment #1

Closed lep1986 closed 6 years ago

lep1986 commented 6 years ago

Nice work! Can you add disable, enable host with comment ?

rrg92 commented 6 years ago

Hello @lep1986 ,

Zabbix API dont support disabling hosts with a comment. But if you want disable the host and add a description with reason for disabling, this is already supported using this module:

import-module power-zabbix;

# authenticates
Auth-Zabbix -Url http://myzabbix/zabbix

# Get a sample host for disable...
#We want retrieve just properties status and description. Just it will be updated
$MyHost = Get-ZabbixHost -Name "MyHost"  -output "status","description"

# Update the status of it (1 = disabled)
# https://www.zabbix.com/documentation/3.0/manual/api/reference/host/object
$MyHost.status = 1 

#Updates the description fiedl!
#Add a line break and some text!
$MyHost.description  += "`nDisabled due some reason"

#Updates the host on server
$MyHost | Update-ZabbixHost
lep1986 commented 6 years ago

WOW! You're unbelievable! Amazing! Thank you!