Zabbix API - Create Maintenance Window: Unterschied zwischen den Versionen
Aus Wiki-WebPerfect
Admin (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „<source lang = "powershell"> $credential = Get-Credential $baseurl = 'https://zabbix.xaas.swissic.ch/zabbix' $params = @{ body = @{ "jsonrpc"= "2…“) |
(kein Unterschied)
|
Version vom 16. Mai 2017, 13:55 Uhr
$credential = Get-Credential $baseurl = 'https://zabbix.xaas.swissic.ch/zabbix' $params = @{ body = @{ "jsonrpc"= "2.0" "method"= "user.login" "params"= @{ "user"= $credential.UserName "password"= $credential.GetNetworkCredential().Password } "id"= 1 "auth"= $null } | ConvertTo-Json uri = "$baseurl/api_jsonrpc.php" headers = @{"Content-Type" = "application/json"} method = "Post" } $result = Invoke-WebRequest @params $params.body = @{ "jsonrpc" = "2.0" "method" = "maintenance.create" "params" = @{ "name" = "Test-RHE" "description" = "Test-RHE-Beschreibung" "active_since" = 1494921600 "active_till" = 1514826000 "hostids" = @('10347') "groupids" = @() "maintenance_type" = 0 "timeperiods" = @( @{ "timeperiod_type" = 0 "start_date" = 1494932400 "period" = 3600 }) } auth = ($result.Content | ConvertFrom-Json).result id = 13 } | ConvertTo-Json -Depth 100 $result = Invoke-WebRequest @params $result = $result.Content | ConvertFrom-Json