Quantcast
Channel: THWACK: All Content - Orion SDK
Viewing all articles
Browse latest Browse all 2677

Alert Acknowledgment Powershell Rest API

$
0
0

I am trying to Acknowledge alerts via the powershell Invoke-RestMethod cmdlet. I have not had any luck, I always receive --  Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.


# Since the certificate in Orion for SWIS is self-signed we'll need this to ignore it.

add-type @"

    using System.Net;

    using System.Security.Cryptography.X509Certificates;

    public class TrustAllCertsPolicy : ICertificatePolicy {

        public bool CheckValidationResult(

            ServicePoint srvPoint, X509Certificate certificate,

            WebRequest request, int certificateProblem) {

            return true;

        }

    }

"@

[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

 

$API_URL = "https://servername:17778/SolarWinds/InformationService/v3/Json/Invoke/Orion.AlertStatus/Acknowledge"

 

$Post = @{

    DefinitionId = '8aaa3f9e-ba13-425f-b662-069d06a17383'

    ObjectType = 'Interface'

    ObjectId = '5644'

    Notes = 'Testing ACK With API'

    }

 

$Json = $Post | ConvertTo-Json

 

#Invoke the Rest Method

$Response = Invoke-RestMethod -Method Put -Uri $API_URL -ContentType "application/json" -Body $Json -UseDefaultCredentials


I can easily get alerts like below.

 

$Query = "SELECT AlertDefID, ActiveObject, ObjectType, Acknowledged, Notes, AlertObjectID FROM Orion.AlertStatus Where Acknowledged = 0"

 

#API Url for Alerts

$API_URL = "https://servername:17778/SolarWinds/InformationService/v3/Json/Query?query=$Query"

 

#Invoke the Rest Method

$Alerts = Invoke-RestMethod -Method Get -Uri $API_URL -ContentType "application/json" -UseDefaultCredentials


Viewing all articles
Browse latest Browse all 2677

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>