Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add-Device with Parmeter not working anymore #276

Closed
schoenm1 opened this issue Mar 4, 2022 · 2 comments
Closed

Add-Device with Parmeter not working anymore #276

schoenm1 opened this issue Mar 4, 2022 · 2 comments
Labels
bug Issues that have been confirmed to be bugs in PrtgAPI and will be fixed in a future version

Comments

@schoenm1
Copy link

schoenm1 commented Mar 4, 2022

Describe the bug

We have an automation script.
Before PRTG Update to 21.4.73.1656+, everything was working.
But no, the script can not add a device anymore.
In our script:
$Device = $DeviceGroup | Add-Device $currentRow.Name $currentRow.Host

[DBG]: PS C:\Visual_Studio\net-team\monitoring\macd> $DeviceGroup | Add-Device $currentRow.Name $currentRow.Host

'Add-Device' failed to resolve device: object is still being created. Retries remaining: 4
'Add-Device' failed to resolve device: object is still being created. Retries remaining: 3
'Add-Device' failed to resolve device: object is still being created. Retries remaining: 2
'Add-Device' failed to resolve device: object is still being created. Retries remaining: 1
Add-Device : Could not resolve object: PRTG is taking too long to create the object. Confirm the object has been created in the Web UI and then attempt resolution again manually.
At line:1 char:16
+ $DeviceGroup | Add-Device $currentRow.Name $currentRow.Host
+                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-Device], ObjectResolutionException
    + FullyQualifiedErrorId : PrtgAPI.ObjectResolutionException,PrtgAPI.PowerShell.Cmdlets.AddDevice

=> Device is added in PRTG / only response is missing
Same issue when I change command to
Add-Device -Name $currentRow.Name -Host $currentRow.Host -Destination $DeviceGroup
But when I try to add a device manually, it is working.

Add-Device -Name bla -Host 1.2.3.4  -Destination $DeviceGroup

Name                        Id     Status      Host            Sensors    Group                     Probe
----                        --     ------      ----            -------    -----                     -----
bla                         52373  Up          1.2.3.4         0          Test-Group            LocalProbe

Even if I entert the string from param manually, it is working

[DBG]: PS C:\Visual_Studio\net-team\monitoring\macd> $currentRow.Name
 su-sw-3og03
[DBG]: PS C:\Visual_Studio\net-team\monitoring\macd> $currentRow.Host
10.10.10.106
[DBG]: PS C:\Visual_Studio\net-team\monitoring\macd>  $DeviceGroup | Add-Device "su-sw-3og03" "10.10.10.106"

Name                        Id     Status      Host            Sensors    Group                     Probe
----                        --     ------      ----            -------    -----                     -----
su-sw-3og03              52374  Up          10.10.10.106   0          Test-Group             LocalProbe

Steps to reproduce

One different I found with '-verbose' command. This could explain the issue.

Working:
Add-Device -Name "su-sw-3og03" -Host "10.10.10.106" -Destination $DeviceGroup -verbose
https://prtg.domain.com/adddevice2.htm?name_=su-sw-3og03&host_=10.10.10.106&ipversion_=0&discoverytype_=0&discoveryschedule_=0&id=16768&username=myuser&passhash=******
=> no "+" before "su-sw-3og3

Not working:
And here is the point I found.
Write-Host "MyString = '$($currentRow.Name)'"
MyString = ' su-sw-3og03' => Leading Space in String before 'su-sw-3og3'
If I try this with fix value (no param) -> same issue.
Add-Device -Name " su-sw-3og3" -Host "10.10.10.106" -Destination $DeviceGroup -verbose
https://prtg.domain.com/adddevice2.htm?name_=+su-sw-3og3&host_=10.10.10.106&ipversion_=0&discoverytype_=0&discoveryschedule_=0&id=16768&username=myuser&passhash=******
=> "+" before "su-sw-3og3

Could this be a general issue. Is it possible you can add this to the PRTGApi Module to catch the error or not to send the "+" sign?
It took me a long time to find the issue (hope this there is not a 2nd issue". Other PRTGApi User should not be affected with same issue (I think this is (again) a PRTG Issue and not PRTGAPI, but you can handle this error where Paessler will not).

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

PSVersion      : 5.1.17763.2268
PSEdition      : Desktop
OS             : Microsoft Windows 10 Enterprise LTSC
PrtgAPIVersion : 0.9.17
Culture        : de-CH
CLRVersion     : .NET Framework 4.8 (528049)
PrtgVersion    : 21.4.73.1656
PrtgLanguage   : Unknown

Additional context

No response

@schoenm1 schoenm1 added the alleged-bug Bugs raised by people helpfully using the Bug Report template! label Mar 4, 2022
@lordmilko
Copy link
Owner

Hi @schoenm1,

So are you saying the issue is that in your CSV, there is a leading space before "su-sw-3og3"?

@schoenm1
Copy link
Author

schoenm1 commented Mar 5, 2022

Hi @lordmilko
Yes, I found this issue because there was a leading space in my excel/csv. " su-sw-3og3" and not "su-sw-3og3"
But even if I try to use PRTGApi wich 'Add-Device -Name ' and a leading space in <myname<, I won't get a reply from PRTG Server that the object was created.

@lordmilko lordmilko added bug Issues that have been confirmed to be bugs in PrtgAPI and will be fixed in a future version and removed alleged-bug Bugs raised by people helpfully using the Bug Report template! labels Mar 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that have been confirmed to be bugs in PrtgAPI and will be fixed in a future version
Projects
None yet
Development

No branches or pull requests

2 participants