Hi I am getting a consistent error when trying to extract data using powershell. I have gone through the history of the sensor and can not find the value the is being reported as an error. Do you now of a way of making powershell ignore the error and continue to pull the rest of the data?
Many thanks
David
Article Comments
Hi Benjamin I am using the following script:-
Get-Sensor "Total Draw" | Get-SensorHistory -Average 3000 -startdate 31/03/2020 -enddate 01/03/2020 | Export-Csv -path C:\Temp\TD1.csv -NoTypeInformation I get 773240 rows of data then get a duplicate value mismatch error part way through one of the sensors.
Many thanks
David
Jun, 2020 - Permalink
David,
Where did you get this PowerShell script? I need to see what these switches do.
Benjamin Day
[Paessler Support]
Jun, 2020 - Permalink
Hi Benjamin I got most of it from the web and amended it until it worked to the point I have it now. I have got info from your knowledge base, github and a file I found that I opened in code writer can't remember where.
Sorry I can't be of more help
Thanks
David
Jun, 2020 - Permalink
David,
Without knowing the switches, or having any reference, I'm afraid I can't be much help here.
Anything you can remember about it can help me.
Benjamin Day
[Paessler Support]
Jun, 2020 - Permalink
Hi Benjamin I used the info in this\PTF. PrtgAPI-master\README.md from https://github.com/lordmilko/PrtgAPI I believe this person works for your organisation. We have used other bits of script fro other knowledge base articles. I do not know anything about the code so have just been trying to cobble this together to get the result I want which is:- a list of all total draw sensors with their values over a month. Exported to an excel file. This I will need to do every month. I can then use a pivot table to get the max draw and we can charge our customer accordingly
If you can recommend something that would be very helpful.
Thanks
David
Jun, 2020 - Permalink
Hi Benjamin Is it possible to send you the PRTGAPI master file where some of the info is?
Thanks
David
Jun, 2020 - Permalink
David,
Can you try running this command?
Get-Sensor "Total Draw" | Get-SensorHistory -Average 3000 -startdate 01/03/2020 -enddate 31/03/2020 | Export-Csv -path C:\Temp\TD1.csv -NoTypeInformation
I just want to make sure this isn't because the dates were swapped around.
Benjamin Day
[Paessler Support]]
Jun, 2020 - Permalink
Hi Ben
I have tried the command as you asked and I brought back this error
Get-SensorHistory : PRTG was unable to complete the request. The server responded with the following error: Not enough monitoring data.
At line:1 char:27 + ... tal Draw" | Get-SensorHistory -Average 3000 -startdate 01/03/2020 -en ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Get-SensorHistory], PrtgRequestException + FullyQualifiedErrorId : PrtgRequestException,PrtgAPI.PowerShell.Cmdlets.GetSensorHistory
this error kept continuing until I canceled the command. I believe the dates have to be the way they were as we tried other ways and it didn't work.
Thanks
David
Jun, 2020 - Permalink
David,
Does this sensor have history for the month of March? How much of the month of March is populated?
Benjamin Day
[Paessler Support]
Jun, 2020 - Permalink
Hi Ben Yes the sensor has data with the start and end dates in the format we were using we were getting data. With the date in the format in your command string we get no data. The issue I am trying to resolve is why the report would stop at 770K lines of data. If you would like to do a team viewer session i can show you.
Hope this helps
Thanks
David
Jun, 2020 - Permalink
Hi Ben Yes all the sensors have data they are polled every ten minutes.
Thanks
David
Jun, 2020 - Permalink
David,
Are you running the latest stable release of PRTG? The latest stable is 20.2.59.
Please update to this version if you aren't currently running it.
Benjamin Day
[Paessler Support]
Jun, 2020 - Permalink
Hi Ben we are running 20.0.58 I will request that the software be updated and come back to you when it has been done.
Many Thanks
David
Jun, 2020 - Permalink
David,
What script are you using?
Benjamin Day
[Paessler Support]
Jun, 2020 - Permalink