I wrote a simple script to check to see if the PRTG console is installed on one of the desktop Windows PC's I am monitoring:

$installed = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName | Select-String -Pattern "PRTG" | Get-Unique | Measure-Object -line
write-host $installed.Lines

I tested this on one of the target machines and got the integer 1 back, as expected. However, the script appears to be getting the result off the core server, not the machine the sensor is under. I tried changing the program in Select-String to check for a program that is only on the core server, and sure enough it reported that correctly.

I want to check the target computer for the installed programs, so I'm not sure what I'm doing wrong


Article Comments

Hello there,
thank you for your inquiry.

You're absolutely correct in your observations. The script is running on the Core because the sensor was deployed on the Local Probe. This is expected, since PRTG runs all sensors on the corresponding probe.

What needs to be done, is improve your script so that it can talk to remote hosts (and configure PRTG to pass the host as command-line parameter when it runs the script, using the %host variable in the parameters field).

There are two ways to do this:

  1. Use the -computername parameter, to run the cmdlet against a remote system (not all cmdlets support this)
  2. Use "Invoke-Command" to run everything remotely.

Please keep in mind that in both cases, you also need to take authentication into consideration, since the probe service runs scripts with the LOCAL_SYSTEM account by default (so this is the security context, when the script runs).

Please refer to the following KB-Post, as it refers to a very similar case where a different customer ran into this issue, and shared his final working script with necessary adjustments:

The following KB-Post also contains tips and tricks to get powershell-based sensors runnning:

Best Regards,
Luciano Lingnau [Paessler Support]


Jun, 2018 - Permalink

Thanks for your help! Decided to go with a Python script instead but the references will be useful for later on.


Jun, 2018 - Permalink