What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

PRTGAPI cannot use command Connect-PrtgServer

Votes:

0

@lordmilko

This has been working fine for me up until this afternoon. As far as I know nothing has changed. Help please :)

Connect-PrtgServer -Credential $cred -Server $server 
Connect-PrtgServer : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
At line:2 char:1
+ Connect-PrtgServer -Credential $cred -Server srhqnms02.scotrailcorp.c ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-PrtgServer], WebException
    + FullyQualifiedErrorId : System.Net.WebException,PrtgAPI.PowerShell.Cmdlets.ConnectPrtgServer

api lordmilko powershell

Created on Apr 9, 2018 3:47:40 PM



5 Replies

Votes:

0

Hi there,

Are you able to manually connect to "srhqnms02.scotrailcorp.com" via HTTPS? It seems that the webserver either uses is using a certificate that is not trusted or that the Webserver of PRTG is not using HTTPS at all.

Best regards.

Created on Apr 10, 2018 10:22:18 AM by  Dariusz Gorka [Paessler Support]



Votes:

0

Hi Matthew,

For issues with PrtgAPI you should open an issue on GitHub rather than use Paessler's forums

I think Dariusz is correct; has your certificate expired?

PrtgAPI does not disable the .NET Framework's default SSL validation mechanism, as since PRTG supports both HTTP and HTTPS, there is no reason to configure your PRTG server to use HTTPS unless you actually have a valid certificate.

You will likely find that executing an Invoke-WebRequest command such as

https://prtg.example.com/api/table.xml?content=sensors&columns=objid,name&count=1&username=prtgadmin&password=prtgadmin

will also fail if there are any issues on your PRTG server or your network preventing SSL from working properly

Also, FYI since Server and Credential are positional parameters, you don't need to specify their parameter names

Connect-PrtgServer $server $cred

Regards,

lordmilko

Created on Apr 10, 2018 12:37:55 PM



Votes:

2

At least one thing has changed since it worked fine: time
Is the certificate expired?

Created on Apr 10, 2018 12:47:53 PM



Votes:

1

Hi there,

lordmilko, good to know that you check GitHub issues. I am sure that we can solve this one also here as it might not be linked to underlying code of your great and handy tool!

PRTGToolsFamily, that is true! Maybe the certificate had expired a couple days ago.

Best regards.

Created on Apr 10, 2018 7:05:14 PM by  Dariusz Gorka [Paessler Support]



Votes:

0

I'm so sorry for the late reply. I only just saw the responses today - I don't know why I didn't get emails letting me know you all had responded.

We don't have a certificate yet (and never did). I figured out that I had removed a section of code that ignored invalid certificates from my PowerShell profile by accident.

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

All is well now and we are still working on getting a certificate set up.

Created on May 4, 2018 10:56:49 AM




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.