Jannos-443
Using WinRM and WMI this script counts logged on users.
You can exclude users or include only one or two users.
-
Place
PRTG-LoggedOnUser.ps1
underC:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML
-
Create new Sensor
Settings Value EXE/Script Advanced PRTG-LoggedOnUser.ps1 Parameters -ComputerName %host Security Context Use Windows credentials of parent device" or use "-Username" and "-Password" -
If needed set the "$IncludePattern" or "$ExcludePattern" parameter to include or exclude users
If you connect to Computers by IP or to not Domain Clients please read Microsoft Docs.
you maybe have to add the target to the TrustedHosts on the PRTG Probe
example: Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value "IPAdressOfMyTarget,HostnameOfMyTarget"
check if the user "TestUserContoso" is logged on and if not show an Error
set PRTG-LoggedOnUser.ps1 -ComputerName %host -IncludePattern '^(TestUserContoso)$'
and set the Lower Error Limit
You can either use the parameter $IncludePattern or $ExcludePattern to exclude on sensor basis, or set the variable $ExcludeScript within the script. Both variables take a regular expression as input to provide maximum flexibility. These regexes are then evaluated againt the Username
For more information about regular expressions in PowerShell, visit Microsoft Docs.
".+" is one or more charakters ".*" is zero or more charakters