Hi,
I am currently using the Microsoft Platform connector to monitor a few terminals and would like to know whether it is possible to return the named users currently logged on to the terminals.
Hi,
That info is currently not available in the Microsoft Platform connector. However, it seems possible to add this if the information from Win32_LoggedOnUser in combination with Win32_LogonSession would be polled via WMI.
Regards,
If I query the Win_32_LoggedOnUser then I’m getting back a list with instances of logged in users. When clicking on it, I can see in the Antecedent property the domain and name of the user. The Dependent property shows the matching LogonId. When querying Win32_LogonSession it’s returning also a list with instances. When clicking on an instance, it’s having the property LogonId that matches with the Dependent property of previous query (so the user name can be mapped) and other properties can be consulted like the StartTime when the session started, LogonType (2 = Interactive, like a user being logged on by a terminal server)
I believe this is currently not implemented in the Microsoft Platform connector. However this info should be available to retrieve via WMI. There's a class "win32_ComputerSystem" that returns a parameter "Username" that shows what user is logged on at the moment.
https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-computersystem
This is something that could be implemented in the connector.
I tested this with Windows Server 2019 Standard and there the UserName stays empty. Under Windows 11 it is being filled in. Seems like that property is not filled in in all cases.
Hi,
Maybe another option is to use the command:
query user
Checking the documentation available at Microsoft, this command is valid for Windows Server 2022, Windows Server 2019, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/query-user
It is true that it is not a WMI query, but it could be an option in case we don’t find a WMI query that works for all Windows OS.
I further investigate this: this UserName property returned with the Win32_ComputerSystem returns the name of the user that is physically sitting at the computer. If nobody is sitting at the computer, but logs in through remote desktop then the UserName property will be empty. When I checked the Win11 I was physically sitting at it, when I checked the Win2019 I was connected via remote desktop which explains what I was seeing. Remote desktop to Win11 also gives an empty Username.
To summarize:
-If you only want to know who is logged in that is physically sitting at the computer (looking at that screen, using the keyboard and mouse attached to that computer) then Win32_ComputerSystem, UserName can be used.
-If you want to know everyone that is logged in to that computer (both physically and remote desktop sessions) then this can be derived from the queries that I’ve written in my answer
Tested this and at first sight didn’t seem to give useful data…