Closed xcom923 closed 5 years ago
I'm sorry the rest of the error is
- CategoryInfo : NotSpecified: (:) [Get-Channel], XmlDeserializationException
- FullyQualifiedErrorId : PrtgAPI.XmlDeserializationException,PrtgAPI.PowerShell.Cmdlets.GetChannel
Hi @xcom923,
Are you able to advise what type of sensor this is?
Can you also advise what version of PrtgAPI you're running, whether this issue occurs on any other computers (if possible) and also the exact version you're running (by running the winver
command), whether you may have recently installed Windows Updates, whether you've ever successfully been able to use the Get-Channel
cmdlet before and also whether it is happening on all sensor types you test with
This issue sounds just like this one, which was caused by a rogue Windows Update breaking .NET applications in general
Sorry for the delay. I thought it would be that one but I couldn't find that update installed on my machine. Then I tested this out on the PRTG server itself which is on a Win server 2012R2. I'm seeing the same error on that one. The sensor is a CPU sensor. As for the version are you talking about the API version? (0.9.2) I had just installed this and our PRTG is also the latest (to my knowledge) at 18.4.45.1898+
I tried some random sensors and got the same error, so it's not just cpu types.
Can you please confirm what the value is of the Access
property on these sensors you're trying to retrieve channels for?
Get-Sensor -Id 15210|select Access
I've discovered that when you don't have write permissions (either Write
or Full
) PRTG will not include the <input>
tags of all the channel properties in the response, resulting in the behavior we are seeing. (Note that if the access is Inherited
you may need to instead check the Access
of the sensor's parent object)
Failing that, can you attempt to run the following command and advise whether you get an error
Set-ChannelProperty -SensorId 15210 -Id 0 -UpperErrorLimit 123
If you do have Write or Full access permissions or can modify a channel property, can you please follow my original response below
Can you please run the following command
Get-Sensor ping -count 1 | Get-Channel -Verbose
That should result in output similar to the following
VERBOSE: Get-Channel: Synchronously executing request
https://prtg.example.com/api/table.xml?content=channels&columns=objid,name,lastvalue&count=*&id=10006&username=prtgadmin&passhash=12345678
VERBOSE: Get-Channel: Synchronously executing request
https://prtg.example.com/controls/channeledit.htm?id=10006&channel=0&username=prtgadmin&passhash=12345678
Can you please copy the first URL executed against channeledit.htm
and then execute the following command (substituting the URL for whatever your channeledit.htm
url was) and advise what the output is
(iwr "https://prtg.example.com/controls/channeledit.htm?id=10006&channel=0&username=prtgadmin&passhash=12345678").inputfields|select name,outerhtml
You should get a response similar to the following
name outerHTML
---- ---------
name_0 <INPUT id=name_0 class=text value="Ping Time" name=name_0 autocomplete="off" data-rule-requ...
showchart_0 <INPUT id=showchart1 class="hidden radio " CHECKED type=radio value=1 name=showchart_0>
showchart_0 <INPUT id=showchart0 class="hidden radio " type=radio value=0 name=showchart_0>
show_0 <INPUT id=show1 class="hidden radio " CHECKED type=radio value=1 name=show_0>
show_0 <INPUT id=show0 class="hidden radio " type=radio value=0 name=show_0>
colmode_0 <INPUT id=colmode0 class="hidden radio GroupShowHide" CHECKED type=radio value=0 name=colm...
colmode_0 <INPUT id=colmode1 class="hidden radio GroupShowHide" type=radio value=1 name=colmode_0>
color_0 <INPUT id=color_0 class="text colorselector" name=color_0 autocomplete="off" data-rule-requ...
linewidth_0 <INPUT id=linewidth_0 class=text value=1 name=linewidth_0 autocomplete="off" data-rule-requ...
percent_0 <INPUT id=percent0 class="hidden radio GroupShowHide" CHECKED type=radio value=0 name=perc...
percent_0 <INPUT id=percent1 class="hidden radio GroupShowHide" type=radio value=1 name=percent_0>
ref100percent_0 <INPUT id=ref100percent_0 class=text name=ref100percent_0 autocomplete="off" data-rule-numb...
ref100percent_0_factor <INPUT id=ref100percent_0_factor type=hidden value=1 name=ref100percent_0_factor>
avgmode_0 <INPUT id=avgmode0 class="hidden radio " CHECKED type=radio value=0 name=avgmode_0>
avgmode_0 <INPUT id=avgmode1 class="hidden radio " type=radio value=1 name=avgmode_0>
avgmode_0 <INPUT id=avgmode2 class="hidden radio " type=radio value=2 name=avgmode_0>
decimalmode_0 <INPUT id=decimalmode0 class="hidden radio GroupShowHide" CHECKED type=radio value=0 name=...
decimalmode_0 <INPUT id=decimalmode1 class="hidden radio GroupShowHide" type=radio value=1 name=decimalm...
decimalmode_0 <INPUT id=decimalmode2 class="hidden radio GroupShowHide" type=radio value=2 name=decimalm...
decimaldigits_0 <INPUT id=decimaldigits_0 class=text value=2 name=decimaldigits_0 autocomplete="off" data-r...
spikemode_0 <INPUT id=spikemode0 class="hidden radio GroupShowHide" CHECKED type=radio value=0 name=sp...
...
Can you please advise what output here is?
Hi @xcom923,
Just following up on this. Are you potentially able to advise whether you are limited to read only access on the sensors you are trying to interface with?
I am close to releasing PrtgAPI 0.9.3, which will contain a number of fixes pertaining to interfacing with PRTG with read only user permissions, This will certainly resolve your issue, however I would just like to confirm there wasn't some other reason PRTG isn't returning certain channel properties so I may include all required fixes in this release
Regards, lordmilko
I'm sorry about being a ghost on this subject. I need to get something to my superiors so I ended up using the REST API. To answer your question, yes I am using an account with RO access. We try to grant more permissions than needed. At the time I didn't think I would need anything more than RO access. Please let me know when the update is released. I'll try out the new version since I still would like to be able to use more than one tag for my project.
Hi @xcom923 ,
I have compiled a release candidate for PrtgAPI 0.9.3 which should include a fix for this issue. Can you please perform the following steps and confirm whether the issue has been resolved?
Get-Sensor -count 1 | Get-Channel
and Get-Sensor -count 1 | Get-ObjectProperty
Regards, lordmilko
Hi @xcom923,
Based on my testing I am confident this issue has been resolved. As such, PrtgAPI 0.9.3 has now been released.
To update to the latest version, please run Update-Module PrtgAPI
and then reopen PowerShell
Regards, lordmilko
Thanks for the info. Not sure if I'll be able to test it out any time soon with the holidays coming up combined with a big EOY project (shoot me now) I'll let you know as soon as I get a chance to test this though.
when I try to use Get-Channel (I've tried passing the sensor and also just using the sensor ID), I keep getting the following
Get-Channel : An error occurred while attempting to deserialize XML element 'injected_showchart': cannot assign 'null' to value type 'Boolean'.
again I've tried doing
$sensor | Get-Channel
from a for loop where $sensor is the individual sensor. I also outputted the sensor ID just to make sure that the sensor had correct dataGet-Channel -SensorId 15210
this one I just used the ID and I still got the same error.