For users who don't want to run some .EXE, I just figured out how to form PowerShell scripts & execute as a Custom/EXE probe.
First of all, I will mention that my PRTG core service & probe are running as service accounts in my domain. This account was given the privileges to execute remote commands on any machine I am running my PS scripts against.
I wrote a simple PS script that is the following:
param($compname)
$x= query user /server:$compname
$y = $x.count.toString()
write-host $y":OK"
Remark: See adjusted version below that won't return "-1" in case no user is logged in.
To break this script down to its components: The first line takes IN a PARAMETER which will be set up for the PROBE later.
Then it executes the Query User command, specifying the computername passed to the script from the PRTG probe.
The next line gets the .count and converts it to a string, because PRTG seemed to not be able to handle it if it was not.
Then, finally it puts the value, and the Required ':OK' string that PRTG custom EXE's and scripts seem to require.
This script must be saved as "Something.ps1" in the PRTG EXE/Script Area, which by default in Windows appears to be C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE\.
From there, I followed the instructions on this article: https://www.paessler.com/manuals/prtg/exe_script_sensor
But some details: USE INTEGER, not "Counter", for all these!
Add comment