Invoke-IcingaCheckUsers or other possiblities to check logged in Users

Hello everyone,

I’m currently having a bit of trouble with Icinga for Windows to create a user check that just gives me just the number of users that are currently logged in. So no service users or anything, just the people that are currently connected to the remote-desktop-server via rdp.

With the Invoke-IcingaCheckUsers module I don’t get this displayed either, because there I get all users (including service users and so on) displayed and not only those who are connected via RDP. And I can’t use the user filter here because it would be impossible to enter every user manually that exists in the Active Directory.

Also my attempts to write my own module using qwinsta, query user or query session have failed so far because these commands also dont display the real number. What would be perfect, is to see just the currently via rdp connected users with status = active.

Does anyone here have an idea how I can query this or even already has a module for it? At first glance I actually thought this is simple thing to do but it is probably more difficult than expected.

Many thanks in advance and kind regards

I have written a powershell script some time ago that uses qwinsta.

# Run the qwinsta.exe and parse the output 
			$queryResults = (qwinsta /server:$ServerName | foreach { (($_.trim() -replace "\s+",","))} | ConvertFrom-Csv)  
			# $queryResults
			# Pull the session information from each instance 
			$ICA_Sessions = 0
			$RDP_Sessions = 0
			ForEach ($queryResult in $queryResults) { 
				#$RDPUser = $queryResult.USERNAME 
				$sessionType = $queryResult.SITZUNGSNAME
				#$sessionType 
				if ($sessiontype -like "ICA*") {$ICA_Sessions++}
				elseif ($sessionType -like "RDP*") {$RDP_Sessions++}
			}

you most likely will have to change some parameters, due to the script was for german windows installations.
Haven’t used this in some time though, so I don’t knwo if this still works.

1 Like

Looks good at first sight, I will give it a try.

German windows is fine or rather it even makes it easier for me because thats also what we are running mostly.

Thank you very much!