lordmilko / PrtgAPI

C#/PowerShell interface for PRTG Network Monitor
MIT License
305 stars 38 forks source link

Set-ObjectProperty Device #275

Closed ArneBrucker closed 2 years ago

ArneBrucker commented 2 years ago

What's going on?

Get-Device -Id 4294 | Set-ObjectProperty -Location "Koenneritzstrasse 47, 04229 Leipzig"

Set-ObjectProperty : PRTG was unable to complete the request. The server responded with the following error: Die Validierung Ihrer Eingaben war nicht erfolgreich: Die Werte in 'Ortsangabe (für Geo Maps)' haben entweder ein ungültiges Format oder sind außerhalb des zulässigen Bereichs. . Das Objekt wurde nicht geändert.

Something went wrong - I do not understand why?

Due Dilligance

lordmilko commented 2 years ago

Hi @ArneBrucker,

This location worked for me on my dev PRTG server; can you please provide the output of Get-PrtgClient -Diagnostic?

ArneBrucker commented 2 years ago

Hello @lordmilko

thanks for the fast replay:

PS C:\Windows\system32> Get-PrtgClient -Diagnostic

PSVersion : 5.1.17763.2268 PSEdition : Desktop OS : Microsoft Windows Server 2019 Standard PrtgAPIVersion : 0.9.16 Culture : de-DE CLRVersion : .NET Framework 4.8 (528049) PrtgVersion : 22.1.74.1869 PrtgLanguage : german.lng

lordmilko commented 2 years ago

Are you able to advise if setting other addresses work, or if it's just that 1 address that doesn't work?

If other addresses don't work, have you previously successfully set an address using PrtgAPI? When was that?

Can you set the address that isn't working using the PRTG UI?

ArneBrucker commented 2 years ago

Hi @lordmilko

I tried to put in several adresses no one works right now - this is the first time I will use Set-ObjectProperty to change Device settings - so if the cmdlt ever worked properly I do not know.

lordmilko commented 2 years ago

If you try and do any of these addresses that don't work using the PRTG UI are you able to advise whether or not it works?

ArneBrucker commented 2 years ago

Tried 5 - get 5 times a positiv result - so in the PRTG UI it works great

lordmilko commented 2 years ago

In the PRTG UI can you please go to Setup -> System Information -> User Interface and under the Geo Maps section can you advise which Service Provider is selected?

lordmilko commented 2 years ago

Hi @ArneBrucker,

I figured out the issue. The issue is that in the de-DE culture, decimal places are represented using commas instead of periods. As such, when PrtgAPI formats the latitude and longitude into an API request it generates the following

/editsettings?id=2055&location_=K%C3%83%C2%83%C3%82%C2%B6nneritzstra%C3%83%C2%83%C3%85%C2%B8e+47%2C+042
29+Leipzig%2C+Deutschland&lonlat_=12%2C34445%2C51%2C32475&locationgroup=0

If the PRTG server is expecting the lonlat_ property to use dots for decimal places however (i.e. lonlat_=12.34445%2C51.32475) then this will fail.

One question mark remains here however: can you please open a PowerShell on your PRTG Server and go Get-Culture and advise what the result is?

ArneBrucker commented 2 years ago

PS C:\Windows\system32> Get-Culture

LCID Name DisplayName


1031 de-DE Deutsch (Deutschland)

ArneBrucker commented 2 years ago

Hello @lordmilko ,

after some fails I tried to set up the Server with the expected "Culture" - now it is 1033 en-US Englisch (USA) but the Set-ObjectProperty - Location still does not work with adress details like "Dachsstrasse 1, 4329 Leipzig" - The parameter could not resolve - any suggestion?

lordmilko commented 2 years ago

Hi @ArneBrucker,

Apologies for the delay in getting back to you on this. Are you able to confirm whether you are running PrtgAPI on the server with the en-US culture, or are you still using it on your workstation which is de-DE?

ArneBrucker commented 2 years ago

Hello @lordmilko

I changed the Server to US -and work on the Server itself. But both - de-DE and US does not work.

lordmilko commented 2 years ago

Please be advised I have successfully managed to reproduce this issue and am currently investigating

lordmilko commented 2 years ago

Hi @ArneBrucker,

Please be advised I have pushed a new pre-release version of PrtgAPI that should include a fix for this issue

Can you please try running PrtgAPI 0.9.18-preview.3 via the manual installation instructions and advise whether this issue is resolved?

If the issue is still occurring, please confirm that you are in fact using the pre-release version, which will be shown by doing Get-PrtgClient -Diagnostic

ArneBrucker commented 2 years ago

Hello @lordmilko,

I do not find the Version you mentioned (Prtg.API 0.9.18-preview.3) could you please tell me where to download this version?

Thank you Arne

lordmilko commented 2 years ago

Please click the link included in the Manual installation instructions