Build precise queries to find exactly what you need
Press ESC to close
Your review has been submitted and is pending approval.
Checks if a specific user is logged on to a specific system.
Current Version
2.0
Last Release Date
2015-08-26
Owner
R. Peters
License
GPL
Compatible With
This script checks if a specific user is logged on to a specific system. The script will cath any error. Status is OK if the user is logged on, and CRITICAL if not. The computername, name of the domain and username are variable, so the script will accept any supplied value as an argument.
--------- Syntax: ---------
get_user.ps1 computername domain user
- For a remote system, the parameter computername can be a hostname, or an IP address. For the local machine, you can use localhost or a dot (.) as valid values. - The parameter domain is the name of the domain (if the user is a domain user), or the computername (for a local user). - The parameter user is the user logon name.
-------- Notes: --------
- PowerShell scripts must be allowed to run on the target computer (PowerShell Script Execution Policy). - Disconnected user sessions are recognized as logged on users. Which in fact is correct, because with a disconnected session, the user is still logged on to the system.
---------------------------- Installation instructions: ----------------------------
- Put the Powershell script in the C:Program FilesNSClient++Scripts directory. - In the nsclient.ini file, in the section [/settings/external scripts/scripts], add the following line: check_user=cmd /c echo scripts\check_user.ps1 computername domain user; exit $LastExitCode | powershell.exe -command - - Restart the NSClient - On the Nagios server, create a service with the following check command: check_command check_nrpe!check_user! - Restart Nagios
It works fine, we just use the check_nrpe command with user_logon as a parameter. Also we changed the variables to the following format: $hostname=some.domain.com $domain=domain.com $user=domainuser If we left the variables as they where ([string]$param,]) we would get a syntax error. And last: . as a hostname does not work for us. Nor does localhost. FQDN works fine. Might have something to do with checking a domain user/machine. We have a working check, so happy campers. Thanks!
You must be logged in to submit a review.
To:
From: