PrtgAPI icon indicating copy to clipboard operation
PrtgAPI copied to clipboard

$param = Get-Device -id 127399 | New-SensorParameters -RawType exexml -Target PSx64.exe

Open carsten0407 opened this issue 2 years ago • 11 comments

What's going on?

Im trying to add a sensor (exexml) with $param = Get-Device -id 127399 | New-SensorParameters -RawType exexml -Target PSx64.exe get-device -id 127399 | Add-Sensor $params

I get the param, but nothing happens no sensor will added.

scriptplaceholdergroup : 1 scriptplaceholder1description : scriptplaceholder1 : scriptplaceholder2description : scriptplaceholder2 : scriptplaceholder3description : scriptplaceholder3 : scriptplaceholder4description : scriptplaceholder4 : scriptplaceholder5description : scriptplaceholder5 : exefilelabel : exeparams : environment : 0 usewindowsauthentication : 0 mutexname : timeout : 60 writeresult : 0 anti-csrf-token : ZWJmNTc4MjZiZDJjMTY2ZmY2NmJjMThlMzcwMmQ5NGFjZTQ3OTg4OQ== exefile : PSx64.exe Targets : {[exefile, PrtgAPI.Targets.GenericSensorTarget[]]} Source : server.lan.local QueryParameters : SensorType : exexml Priority : Three InheritTriggers : True InheritInterval : True Interval : 00:01:00 IntervalErrorMode : OneWarningThenDown DynamicType : False Name : XML-Programm-/Skriptsensor Tags : {xmlexesensor} Cookie : False

If I try without -target $param = Get-Device -id 127399 | New-SensorParameters -RawType exexml ((((-Target PSx64.)))) the sensor will added but the wrong one with a wrong exefile

Due Dilligance

  • [X] It wasn't covered by the wiki, I swear!
  • [X] I have tried doing some basic research on this issue but haven't been able to come up with anything. Please help!

carsten0407 avatar Jul 01 '23 05:07 carsten0407

PSVersion : 5.1.22621.1778 PSEdition : Desktop OS : Microsoft Windows 11 Enterprise PrtgAPIVersion : 0.9.18 Culture : de-DE CLRVersion : 533320 PrtgVersion : 23.2.83.1760 PrtgLanguage : german.lng

carsten0407 avatar Jul 01 '23 05:07 carsten0407

After executing this line

$param = Get-Device -id 127399 | New-SensorParameters -RawType exexml -Target PSx64.exe

Can you provide the output of $param

$param

In addition, what is the output of

get-device -id 127399 | Add-Sensor $params -Verbose

Please remove any sensitive information (such as your server address, username and passhash) in the verbose output

lordmilko avatar Jul 01 '23 05:07 lordmilko

Here the output

PS C:\Users\BID00422\OneDrive - KME\PRTG_Go_Dropbox\Scripts> $param = Get-Device -id 127399 | New-SensorParameters -RawType exexml -Target PSx64.exe PS C:\Users\BID00422\OneDrive - KME\PRTG_Go_Dropbox\Scripts> $param

scriptplaceholdergroup : 1 scriptplaceholder1description : scriptplaceholder1 : scriptplaceholder2description : scriptplaceholder2 : scriptplaceholder3description : scriptplaceholder3 : scriptplaceholder4description : scriptplaceholder4 : scriptplaceholder5description : scriptplaceholder5 : exefilelabel : exeparams : environment : 0 usewindowsauthentication : 0 mutexname : timeout : 60 writeresult : 0 anti-csrf-token : MzBjMWY1YmU4OGE3NjI0OWMwY2E2MWIwZWE2OTM2ZDk5MWIxYWQzYTdiNzVkZTgwZTdiYTJjZjAyN2VlYzUxYw== exefile : PSx64.exe Targets : {[exefile, PrtgAPI.Targets.GenericSensorTarget[]]} Source : SR.intern.local QueryParameters : SensorType : exexml Priority : Three InheritTriggers : True InheritInterval : True Interval : 00:01:00 IntervalErrorMode : OneWarningThenDown DynamicType : False Name : XML Custom EXE/Script Sensor Tags : {xmlexesensor} Cookie : False

After executing this line

$param = Get-Device -id 127399 | New-SensorParameters -RawType exexml -Target PSx64.exe

Can you provide the output of $param

$param

In addition, what is the output of

get-device -id 127399 | Add-Sensor $params -Verbose

Please remove any sensitive information (such as your server address, username and passhash) in the verbose output

— Reply to this email directly, view it on GitHubhttps://github.com/lordmilko/PrtgAPI/issues/341#issuecomment-1615527332, or unsubscribehttps://github.com/notifications/unsubscribe-auth/APIS7JBKOFA6WXME7IXG4T3XN63QVANCNFSM6AAAAAAZ2SFAHY. You are receiving this because you authored the thread.Message ID: @.@.>>

carsten0407 avatar Jul 01 '23 09:07 carsten0407

get-device -id 127399 | Add-Sensor $param -Verbose

Add-Sensor : PRTG was unable to complete the request. The server responded with the following error: Nothing was selected, no sensors could be created. In Zeile:1 Zeichen:25

  • get-device -id 127399 | Add-Sensor $param -Verbose
  •                     ~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [Add-Sensor], PrtgRequestException
    • FullyQualifiedErrorId : PrtgRequestException,PrtgAPI.PowerShell.Cmdlets.AddSensor

[EXTERNAL E-MAIL] Use caution when following links or opening attachments.

After executing this line

$param = Get-Device -id 127399 | New-SensorParameters -RawType exexml -Target PSx64.exe

Can you provide the output of $param

$param

In addition, what is the output of

get-device -id 127399 | Add-Sensor $params -Verbose

Please remove any sensitive information (such as your server address, username and passhash) in the verbose output

— Reply to this email directly, view it on GitHubhttps://github.com/lordmilko/PrtgAPI/issues/341#issuecomment-1615527332, or unsubscribehttps://github.com/notifications/unsubscribe-auth/APIS7JBKOFA6WXME7IXG4T3XN63QVANCNFSM6AAAAAAZ2SFAHY. You are receiving this because you authored the thread.Message ID: @.@.>>

carsten0407 avatar Jul 01 '23 09:07 carsten0407

Hi @carsten0407,

When you do get-device -id 127399 | Add-Sensor $param -Verbose it displays the raw HTTP request PrtgAPI attempted to execute. It appears you have completely omitted this text. Can you please provide the verbose output with just the server, username and password redacted

lordmilko avatar Jul 01 '23 10:07 lordmilko

AUSFÜHRLICH: Ausführen des Vorgangs "Add-Sensor" für das Ziel "XML Custom EXE/Script Sensor (Destination: SRV-BACKUP01-19.thuemlein.local (ID: 127399))".
AUSFÜHRLICH: Add-Sensor: Synchronously executing request
https://monserver.intern.de/api/table.xml?content=sensors&columns=objid,name,probe,group,favorite,lastvalue,device,downtime,downtimetime,downtimesince,uptime,uptimetime,uptimesince,knowntime,cumsince,lastcheck,lastup,lastdown,minigraph,sc 
hedule,basetype,baselink,notifiesx,intervalx,access,dependency,position,status,comments,priority,message,parentid,tags,type,active&count=*&filter_parentid=127399&filter_type=exexml&username=AA_monserver-PowershellUser&passhash=xxxxxxxxxx
AUSFÜHRLICH: Add-Sensor: Synchronously executing request https://monserver.intern.de/controls/addsensor2.htm?id=127399&sensortype=exexml&username=AA_monserver-PowershellUser&passhash=xxxxxxxxxx
AUSFÜHRLICH: Add-Sensor: Synchronously executing request 
https://monserver.intern.de/addsensor5.htm?name_=XML+Custom+EXE%2FScript+Sensor&priority_=3&inherittriggers=1&intervalgroup=1&interval_=60%7C60+seconds&errorintervalsdown_=1&tags_=xmlexesensor&scriptplaceholdergroup=1&scriptplaceholder1de 
scription_=&scriptplaceholder1_=&scriptplaceholder2description_=&scriptplaceholder2_=&scriptplaceholder3description_=&scriptplaceholder3_=&scriptplaceholder4description_=&scriptplaceholder4_=&scriptplaceholder5description_=&scriptplaceholder5_=&exefil 
elabel=&exeparams_=&environment_=0&usewindowsauthentication_=0&mutexname_=&timeout_=60&writeresult_=0&anti-csrf-token=Nzc5MDJkNzE1OTAxMjdjY2U3ZTg0NzFkNmJhMWU3YzY5MjI4ODJiMzExMDI5MzFmNGY2OWE5ZTc3ZmEzZDdjNg%3D%3D&exefile=PSx64.exe%7CPSx64.exe%7C%7C&sens 
ortype=exexml&id=127399&tmpid=62
Add-Sensor : PRTG was unable to complete the request. The server responded with the following error: Nothing was selected, no sensors could be created.
In Zeile:1 Zeichen:25
+ get-device -id 127399 | Add-Sensor $param -Verbose
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Add-Sensor], PrtgRequestException
    + FullyQualifiedErrorId : PrtgRequestException,PrtgAPI.PowerShell.Cmdlets.AddSensor

carsten0407 avatar Jul 01 '23 16:07 carsten0407

Any updates?

carsten0407 avatar Jul 06 '23 06:07 carsten0407

Strange, if I rename my wanted exefile to 1st place in alphabetical order it works. If not he always uses arcserve.exe Any ideas? 2023-07-07 08_33_22-Window

carsten0407 avatar Jul 07 '23 06:07 carsten0407

Hi @carsten0407,

Please be advised I have managed to reproduce this error and am investigating

lordmilko avatar Jul 08 '23 23:07 lordmilko

I couldn't see anything immediately obvious in my investigation aside from the fact PRTG uses POST to execute addsensor5.htm (PrtgAPI uses GET). This has always been the case and worked without issue; it's possible PRTG have changed things in a recent version such that GET no longer works on this endpoint. A bit of investigation/work would need to be done to try and resolve this; I am currently having medical issues so don't have the time to investigate this at the moment. I'm unable to give any ETA as to when this might be resolved

lordmilko avatar Jul 14 '23 12:07 lordmilko

Hi lordmilko,

take your time

carsten0407 avatar Jul 17 '23 06:07 carsten0407