If you are an IT administrator there will come a time when you find RDP problems and the first step to resolving them is to kill all the session. But how?
Microsoft released a new utility named QUSER in Windows 7 and it applies to their operating systems made since Windows 7 including Server 2012, Server 2016, Server 2019, Server 2022, Windows 8, Windows 10 and Windows 11. QUSER lets you see information about users that are logged in (either locally or on a remote Windows computer), including their ID.
In the example below we use QUSER with the LOGOFF command to log out the only user on server ABCM04.
The commands are:
- Right click on the START button of any machine on the same LAN, and select CMD (ADMIN), or POWER SHELL (ADMIN) or WINDOWS TERMINAL (ADMIN)
user /server:<server-host-name>and press ENTER
- Notice the number in the ID column
logoff <#> /server:<server-host-name>
- If there is more than one user logged in repeat this process for each ID
Another unused but simple command to manage Remote Desktop Sessions is “qwinsta” which can be used as shown below:
PS C:\Users\calga> qwinsta /?
Display information about Remote Desktop Services sessions.
QUERY SESSION [sessionname | username | sessionid]
[/SERVER:servername] [/MODE] [/FLOW] [/CONNECT] [/COUNTER] [/VM]
sessionname Identifies the session named sessionname.
username Identifies the session with user username.
sessionid Identifies the session with ID sessionid.
/SERVER:servername The server to be queried (default is current).
/MODE Display current line settings.
/FLOW Display current flow control settings.
/CONNECT Display current connect settings.
/COUNTER Display current Remote Desktop Services counters information.
/VM Display information about sessions within virtual machines.