lordmilko / PrtgAPI

C#/PowerShell interface for PRTG Network Monitor
MIT License
301 stars 37 forks source link

New-Sensor / Add-Sensor reports Could not authenticate to PRTG; the specified username and password were invalid #347

Closed carlbeechvuw closed 1 year ago

carlbeechvuw commented 1 year ago

Describe the bug

Hi

Apologies - looks like I may have encountered a bug, due to an alteration in PRTG... as we recently upgraded our PRTG installation (everything was working correctly before) PRTG version : PRTG Network Monitor 23.3.86.1520 x64 PRTG API version: 0.9.17, also tried with 0.9.18 - both same outcomes.

I'm able to successfully connect and query get - e.g. get-device works correctly.

However, when I try to add a sensor via Add-Sensor or New-Sensor, it comes back with the error: "Could not authenticate to PRTG; the specified username and password were invalid"

If I try to clone an object, this works correctly (see additional info)

Steps to reproduce

[DBG]: PS D:\GIT\VMAD\PRTG_SCRIPTS>> $a=get-device -id 36960 | Get-SensorTarget wmiService Server

[DBG]: PS D:\GIT\VMAD\PRTG_SCRIPTS>> get-device -id 36960 | New-Sensor -WmiService $a
New-Sensor : Could not authenticate to PRTG; the specified username and password were invalid.
At line:1 char:24
+ get-device -id 36960 | New-Sensor -WmiService $a
+                        ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-Sensor], HttpRequestException
    + FullyQualifiedErrorId : System.Net.Http.HttpRequestException,PrtgAPI.PowerShell.Cmdlets.NewSensor

What is the output of 'Get-PrtgClient -Diagnostic'?

[DBG]: PS D:\GIT\VMAD\PRTG_SCRIPTS>> Get-PrtgClient -Diagnostic

PSVersion      : 5.1.20348.1850
PSEdition      : Desktop
OS             : Microsoft Windows Server 2022 Standard
PrtgAPIVersion : 0.9.18
Culture        : en-NZ
CLRVersion     : 528449
PrtgVersion    : 23.3.86.1520
PrtgLanguage   : english.lng

Additional context

[DBG]: PS D:\GIT\VMAD\PRTG_SCRIPTS>> Get-Sensor ping -count 1 | Clone-Object -DestinationId 36960

Name Id Device Group Probe Status


Ping 36983 testserver testgroup Cluster Probe PausedByUser

carlbeechvuw commented 1 year ago

Additional information - I'm able to manually log into PRTG and manually add sensors so PRTG itself is not broken. I'm also able to create device entries via the API.

Many thanks

Carl.

lordmilko commented 1 year ago

Duplicate of #345

carlbeechvuw commented 1 year ago

Many thanks for the swift reply - I've downloaded and used the latest version and this has cured the issue. :-)