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?

windows quser commandMicrosoft 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:

  1. 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)
  2. Type quser /server:<server-host-name> and press ENTER
  3. Notice the number in the ID column
  4. Type logoff <#> /server:<server-host-name>
  5. If there is more than one user logged in repeat this process for each ID

how to remotely log off usersAnother unused but simple command to manage Remote Desktop Sessions is “qwinsta” which can be used as shown below:

how to use qwinsta command line

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.



2 Comments

Rus · February 14, 2023 at 3:42 pm

Small typo in #2. Type user /server: and press ENTER

Should be quser /server:

I mean, yeah, anyone that read the post should be able to figure that out. We just live in such a copy/paste world I’m afraid the youth will try one time and give up.

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *