Quantcast
Channel: THWACK: Message List
Viewing all articles
Browse latest Browse all 20490

Re: REST API in PowerShell

$
0
0

I have been able to get a basic request to work with this, using the following commands:

 

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

$webClient = New-Object System.Net.WebClient

$realquery = "https://localhost:17778/SolarWinds/InformationService/v3/Json/Query?query=SELECT+NodeID,Caption+FROM+Orion.Nodes+WHERE+Nodes.Vendor='Windows'+AND+Nodes.UnManaged='False'"

$webClient.Credentials = New-Object System.Net.NetworkCredential("Admin","")

$results = $webClient.DownloadString($realquery)

$res = $results | ConvertFrom-Json | select -ExpandProperty results

 

The problem I am having is with the credentials/authentication. I am only able to connect with a local Orion account, not with an Active Directory account that has the same rights. Is there a setting somewhere that needs to be changed to allow Active Directory accounts to authenticate with the REST API?


Viewing all articles
Browse latest Browse all 20490

Trending Articles



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