lordmilko / PrtgAPI

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

PRTG API not able to add devices or pull output #260

Closed vkpichu closed 2 years ago

vkpichu commented 2 years ago

What's going on?

the powershell connects to the PRTG server successfully over http, however https it is throuwing error - this is not the issue I am trying to focus here.

The main issue is even after connecting I am not able to add the device via the command line, below is the copy paste output of the windows powershell, if you need any further info please let me know.

Also I have already created a case and worked with the PRTG team and they eventually was suggesting to check with you.

Please help.

Output from Powershell

PS C:\Users\Administrator> Connect-PrtgServer http://127.0.0.1

cmdlet Connect-PrtgServer at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
Credential
PS C:\Users\Administrator>
PS C:\Users\Administrator>
PS C:\Users\Administrator>
PS C:\Users\Administrator> Get-InstalledModule

Version    Name                                Repository           Description
-------    ----                                ----------           -----------
0.9.16     PrtgAPI                             PSGallery            C#/PowerShell interface for PRTG Network Monitor

PS C:\Users\Administrator> Get-Probe 'FUH Digital Clock Group' | Add-Device 'T2 GF Nurse Stn RDU 491-10.201.162.101' 10.201.162.101 -AutoDiscover
PS C:\Users\Administrator> 

Due Dilligance

lordmilko commented 2 years ago

Hi @vkpichu,

Are you able to advise what the output of

Get-Probe 'FUH Digital Clock Group'

is? In addition, can you provide the output of (with your server, username and passhash obfuscated)

Get-Probe 'FUH Digital Clock Group' | Add-Device 'T2 GF Nurse Stn RDU 491-10.201.162.101' 10.201.162.101 -AutoDiscover -Verbose

as well as

Get-PrtgClient -Diagnostic
vkpichu commented 2 years ago

Thanks for the response lordmilko, I am able to provide the output and those are below

after every command there is nothing much running in the background I feel.

===============================

PS C:\Users\Administrator\Desktop> Connect-PrtgServer http://127.0.0.1

cmdlet Connect-PrtgServer at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
Credential
Connect-PrtgServer : Already connected to server http://127.0.0.1. To override please specify -Force.
At line:1 char:1
+ Connect-PrtgServer http://127.0.0.1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-PrtgServer], InvalidOperationException
    + FullyQualifiedErrorId : System.InvalidOperationException,PrtgAPI.PowerShell.Cmdlets.ConnectPrtgServer

PS C:\Users\Administrator\Desktop> Get-Probe 'FUH Digital Clock Group'
PS C:\Users\Administrator\Desktop> Get-Probe 'FUH Digital Clock Group' | Add-Device 'T2 GF Nurse Stn RDU 491-10.201.162.101' 10.201.162.101 -AutoDiscover -Verbose
PS C:\Users\Administrator\Desktop>
PS C:\Users\Administrator\Desktop>
PS C:\Users\Administrator\Desktop>
PS C:\Users\Administrator\Desktop>
PS C:\Users\Administrator\Desktop> Get-PrtgClient -Diagnostic

PSVersion      : 5.1.17763.1852
PSEdition      : Desktop
OS             : Microsoft Windows Server 2019 Standard Evaluation
PrtgAPIVersion : 0.9.16
Culture        : en-US
CLRVersion     : .NET Framework 4.7.2 (461814)
PrtgVersion    : 21.4.73.1656
PrtgLanguage   : english.lng

PS C:\Users\Administrator\Desktop>

2022-01-04 23_09_44-MPC - Teksalah - Connected

lordmilko commented 2 years ago

The issue here is that Get-Probe 'FUH Digital Clock Group' is not returning any probe, hence when you pipe it to Add-Device nothing happens

Are you able to provide the output of

Get-Probe
vkpichu commented 2 years ago
PS C:\Users\Administrator\Desktop> Get-Probe

Name                      Id     ProbeStatus  Devices                          Groups                          Up Sensors                      Down                            Down (Ack)                      Warning                         Paused
----                      --     -----------  -------                          ------                          ----------                      ----                            ----------                      -------                         ------
Local Probe               1      Connected    399                              10                              504                             28                              0                               0                               0

PS C:\Users\Administrator\Desktop>

vkpichu commented 2 years ago

image

lordmilko commented 2 years ago

Hi @vkpichu,

Based on the output above, it appears you only have a single probe probe called Local Probe, however you have been trying to retrieve a probe called FUH Digital Clock Group. It's possible that your Root Group above all your probes is called FUH Digital Clock Group (you can confirm by running the command Get-Group -Id 0).

If you run

Get-Probe "Local Probe" | Add-Device 'T2 GF Nurse Stn RDU 491-10.201.162.101' 10.201.162.101 -AutoDiscover

you should find this works as expected

vkpichu commented 2 years ago

Get-Probe "Local Probe" | Add-Device 'T2 GF Nurse Stn RDU 491-10.201.162.101' 10.201.162.101 -AutoDiscover

this command executed successfully, but how can I add the device to specific group can u please help me on that ?

lordmilko commented 2 years ago

Use the Get-Group cmdlet to get the group you want

# Get all groups called "Servers"
Get-Group Servers
# Get all groups called "Servers" from the probe called "Chicago"
Get-Probe Chicago | Get-Group Servers

For more information on working with groups please see the wiki

vkpichu commented 2 years ago

Get-Group "FUH VMWare Hosts" | Add-Device 'ttttttttt' 10.9.9.91 -AutoDiscover

so this is how we add a device under group. I figured it out. thanks