If you're curious about who is currently connected to a remote desktop connection, you've come to the right place. There are numerous methods for determining the number of remotely connected users.
RDP, which stands for Remote Desktop Protocol, is a protocol developed and owned by Microsoft that allows a user to connect to another computer via a network connection using a graphical interface. To connect to the server, the user uses RDP client software, whereas the server uses RDP server software, which is included with the Windows Server operating system. When a client connects to a server, Windows Servers keep track of the logged-in user's information, which we can view.
So let's get started.
Using Task Manager
Using Task Manager, we can see a list of active remote desktop users on a Windows server. This method of checking Active User works for every version of Windows Server.
Here are the steps:
- Goto Run and type taskmgr.exe and press the Ok button
This will open Task Manager.
- Just navigate to the Users tab there you will get Users currently active.
It will display a list of users currently logged in. Here, I have only logged so it is showing one user information. Also, it contains information like what application the user is using, its current status, CPU usage, and memory usage.
Here you will only be able to determine which users are using Remote Connection. If you want to know which types of connections are used to connect to the remote, simply click on any column of the list, say "Status," then right-click on it and select "Session." The list will then show a session column with the types of connections to remote, such as console, terminal, services, or RDP, and so on. As shown below.
Using Query User Command
With the help of the query command, we can find various information about sessionId, the number of users, session state(active/inactive) etc on the Remote Desktop Session Host Server. This command can be used to determine whether a specific user is logged in to a specific Remote Desktop Session Host Server or not.
It will return the following information:
- Username: Name of the User.
- sessionname: Name of the session on Remote Desktop Session Host Server. Here, I have rdp-tcp#45
- Id: This is the session ID
- STATE: This is the state of the session either active or disconnected.
- Idle Time: the number of minutes since the session's last keystroke or mouse movement.
- LOGON Time: THis is the login time of the user at the server.
It displays information about not only active sessions but also other sessions that the server is running.
Using quser command
This is the same as the Query User command. This command will also work for Windows Server 2022, Windows Server 2019, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012 only.
Using qwinsta command
Query WINdows STAtion is abbreviated as qwinsta. It displays information about sessions on a Remote Desktop Session Host server. The list includes information not only about active sessions but also about other sessions that the server runs.
Look at the state column and you will see whether the user is active or not. You can see here User with ID 6 is active
Using Get-RDUserSession commandlet
The Get-RDUserSession cmdlet returns a list of all user sessions in a collection or in a Remote Desktop deployment. Note that this may not work in some servers like Windows R2 2012.
Windows Management Instrumentation (WMI) is a PowerShell subsystem that provides administrators with powerful system monitoring tools.
By simply typing the following command you will know a lot:
If you just want to know the username just type the below command:
Using PsLoggedOn Tools
PsTools is a small Sysinternals command-line tool that can help in the administration of local and remote systems. It aids to determine currently logged-in users in local as well as remote systems.
Because PsLoggedOn requires a logon to access the Registry of a remote system, it will show you as logged on via resource share to remote computers that you query.
|Displays the supported options as well as the units of measurement for output values.
|Displays only local logins rather than both local and network resource logons.
|Don't Show Logon times.
|Specifies the name of the compute for which logon information is to be displayed.
|PsLoggedOn searches the network for computers where that user is logged in if you specify a user name. This is useful if you don't want a specific user to be logged in when you're about to change their user profile configuration.
Steps to use PsLogged.
- Download PsLogged from the above link
- Extract the files
- Goto extracted links and an open the command prompt on the same location.
- Then use the syntax mentioned above.
Using Remote Event Viewer
Event Viewer is a powerful Windows tool that allows you to obtain log information from both your local and remote computers.
Connect successfully to a remote computer
Press Ctrl + R and type eventvwr and press Enter. This will open eventvwr.
Just click on the 'Create Custom View' label located at the right corner.
Then under Popup, select Security under 'Event Logs' and type Id in as 4624 ,4647, 4779,4800 and then press Ok.
In the next screen give the Name of the log like 'Remote Login History' and click on Ok.
You will get the 'Remote Login History' Label under Custom Views. Click on the label 'Remote Login History' you will get all login, logout, locked, unlocked event information of the remote users.
Click on the row of the event and detail related to that event will get displayed just below it.
How to Enable Remote Registry Service in Remote Server?
Steps for enabling remote registry service in a remote server are as follows:
- Goto the services manager.
- Look for the "Remote Registry" service.
- Double-click on the service.
- Set the "Start Type" to "Automatic," then press the "Start" button.
- Click OK to save your settings.
Or you can simply run the following line by line in Powershell.
Set-Service is the cmdlet that can modify the StartupType, Status, Description, and Displayname properties of a service. You can start, stop, and suspend service with the help of the Set-Service cmdlet.
Here, Set-Service is looking for RemoteRegistry Service and set this service to start automatically. And -passthru indicates that if you are already running this service then ignore it else run it automatically.
Powershell Script File which displays a List of all User RDP connection
The below script will list all users' RDP Connections History.
- Open Text File and paste the below code.
- Save the file as .ps1
- Open Powershell and type: Powershell.exe -File file_location_path and press Enter
where file_location_path is the actual location of the file
Script Credits go to gstudent@3gstudent
What is happening in the above script?
Ans: To begin, use "reg load" to load the hive. Then, from "HKEY_USERS\"+$User.SID+"\Software\Microsoft\Terminal Server Client\Servers\", read the RDP Connections History. Finally, use "reg unload" to unload the hive. To get the history of login users, data are read from the NTUSER.DAT file.
Differentiate between local and remote desktop users in the Task Manager
Here are some differences:
Remote users require Remote Desktop to log in, while local users are logged in directly on the computer.
To observe the difference, open the Task Manager and locate the Session ID column.
When you open the Task Manager for both local and remote users, you will find that local users have a Session ID of 0, whereas remote users have a Session ID greater than 0.