While testing I found I had an error in the URL and I was incorrect in that the username & passhash are not evaluated. They are! So I created this Powershell script to close the Auto-Discovery Tickets.
$prtguser = "apiuser"
$prtghash = "123456"
$match = "Auto-Discovery *"
$actiontype = "close" # "close" or "resolve"
$message = "auto close"
$hostname = "prtg.yourdomain.com"
$URI = "https://" + $hostname + "/api/table.json?content=tickets&columns=datetime,priority,parentid,message,user,status,name&filter_drel=&username=" + $prtguser + "&passhash=" + $prtghash
$response = Invoke-WebRequest $URI
$jsonObj = $([String]::new($response.Content)) | ConvertFrom-Json | select -expand tickets | select parentid,status_raw,message_raw | Where-Object {($_.message_raw -like $match) -and ($_.status_raw -EQ '1')}
foreach($id in $jsonObj.parentid) {
$actionURI = "https://" + $hostname + "/api/" + $actiontype + "ticket.htm?username=" + $prtguser + "&passhash=" + $prtghash + "&id=" + $id + "&content=" + $message
$result = Invoke-WebRequest $actionURI
$res = $result.Content -replace '<[^>]+>',''
Write-Output "$id - $res"
}
https://gist.github.com/crawc/588e5564eebbc7752943cc91a64c9467
Add comment