I have had a look at the page below and have been able to generate reports and list sensors however what I really want to do is modify sensor settings.
https://helpdesk.paessler.com/en/support/solutions/articles/68506-powershell-interface-for-prtg-api
Is it possible to do something like:
######ignore invalid SSL Certs##########
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
######setup details, access related.
$auth = "username=user&passhash=hash"
$PRTGHost = "IPADDRESS"
function Set-prtgSensorProperty ([string]$SensorID,[string]$PropertyName,[string]$Value)
{
$url = "https://$PRTGHost/api/setobjectproperty.htm?id=$SensorID&name=$PropertyName&value=$Value&$auth"
$request = Invoke-WebRequest -Uri $url -MaximumRedirection 0 -ErrorAction Ignore
} # end function
Obviously I tried that and it didn't work but is there an alternative? Am I missing something?
Article Comments
I figured it out. I was trying to set an inherited property to off and so I needed to use a _ after the property name.
function Set-prtgSensorPropertyInherited ([string]$SensorID,[string]$PropertyName,[string]$Value)
{
$url = "https://$PRTGHost/api/setobjectproperty.htm?id=$SensorID&name=$PropertyName_&value=$Value&$auth"
$request = Invoke-WebRequest -Uri $url -MaximumRedirection 0 -ErrorAction Ignore
} # end function
Mar, 2018 - Permalink
Hi there,
You could try the following. Ignore invalid SSL Cert:
# Ignore SSL errors [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}Request a website:
Does that work?
Best regards.
Mar, 2018 - Permalink