What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

powershell - query terminate with unexpected error by send

Votes:

0

Your Vote:

Up

Down

Hi

If i take my demo script, with support of prtg query builder, i got a error with unexpected by send i startet this demo script directly on my server. i started Windows Powsershell ISE with run as Aministrator Rights

--- start ----  
$benutzer = "hans.mustermann"       
$passwort = "123456789"            
            
$uri = "http://127.0.0.1/api/table.json?content=sensors&columns=sensor&username=$benutzer&passhash=$passwort"
                   
$resulta = Invoke-RestMethod -Uri $uri -ContentType 'application/JSON'

$resulta
--- end -------

Erromessage

Invoke-RestMethod : Die zugrunde liegende Verbindung wurde geschlossen: Für den geschützten SSL/TLS-Kanal konnte keine Vertrauensstellung hergestellt 
werden..

+ $resulta = Invoke-RestMethod -Uri $uri -ContentType 'application/JSON ...
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

If i try to use the command for [ServerCertificateValidationCallback]::ignore(); its not working too

Do you have any clue, how can i easy to view - in the first step to view all data over prtg api. I dont want to use install-module prtg e.g.

Please advise
Thanks
Jochen

connection powershell prtg-api

Created on Dec 30, 2020 2:24:44 PM by  fuzRprubKZe (0) 1

Last change on Dec 31, 2020 7:44:12 AM by  Sven Roggenhofer [Paessler Technical Support]



1 Reply

Votes:

0

Your Vote:

Up

Down

Hi there,

Did you already tried to switch PRTG to HTTP and not HTTPS for troubleshooting? You can also try to use "Invoke-Webrequest" instead of "Invoke-RestMethod" with the follwing addition to ignore the certificate validation:

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

$result = Invoke-WebRequest -Uri "https://IpAddress/resource"

Source: https://stackoverflow.com/questions/11696944/powershell-v3-invoke-webrequest-https-error

Created on Dec 31, 2020 1:12:13 PM by  Moritz Heller [Paessler Support]

Last change on Dec 31, 2020 1:12:35 PM by  Moritz Heller [Paessler Support]



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.