Zabbix API (JSON RPC) with Powershell
Invoke-RestMethod - Method POST - Uri https:// my.org/ zabbix/ api_jsonrpc.php - ContentType application/ json - Body (@ {jsonrpc = " 2.0" ;method = " apiinfo.version" ;params = @ {};id = 1 } | ConvertTo-Json )
(Invoke-RestMethod - Method POST - Uri https:// my.org/ zabbix/ api_jsonrpc.php - ContentType application/ json - Body (@ {jsonrpc = " 2.0" ;method = " user.login" ;params = @ {user = " UserName" ;password = " Password" };id = 1 } | ConvertTo-Json )).result
(Invoke-RestMethod - Method POST - Uri https:// my.org/ zabbix/ api_jsonrpc.php - ContentType application/ json - Body (@ {jsonrpc = " 2.0" ;id = 1 ;auth = " 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" ;method = " host.get" ;params = @ {search = @ {name = " myhost" };output = @ (" hostid" , " name" , " status" )}} | ConvertTo-Json )).result
(Invoke-RestMethod - Method POST - Uri https:// my.org/ zabbix/ api_jsonrpc.php - ContentType application/ json - Body (@ {jsonrpc = " 2.0" ;id = 1 ;auth = " 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" ;method = " host.get" ;params = @ {filter = @ {name = " myhostname" };output = @ (" hostid" , " name" , " status" )}} | ConvertTo-Json )).result
(Invoke-RestMethod - Method POST - Uri https:// my.org/ zabbix/ api_jsonrpc.php - ContentType application/ json - Body (@ {jsonrpc = " 2.0" ;id = 1 ;auth = " 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" ;method = " host.get" ;params = @ {search = @ {name = " myhost" };output = @ (" name" );selectItems = " extend" }} | ConvertTo-Json )).result.items | Select-Object name, key_
List items which "key_" includes "sensor.status" from 5 hosts
(Invoke-RestMethod - Method POST - Uri https:// my.org/ zabbix/ api_jsonrpc.php - ContentType application/ json - Body (@ {jsonrpc = " 2.0" ;id = 1 ;auth = " 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" ;method = " item.get" ;params = @ {hostids = @ (200200000000001 ;200200000000002 ;200200000000003 ;200200000000004 ;200200000000005 );search = @ {key_ = " sensor.status" }}} | ConvertTo-Json )).result | Select-Object hostid, name, lastvalue