Clear all the remote desktop session remotely

My best friend just asked is it possilbe to killing remote desktop session remotely. The reason for doing that was cause by my friend need to physically go back to his office and logon to the server in order to clear the connection in last weekend.
For me, i will try “mstsc.exe /console” to try to remote control the console of that server and disconnect all the other remote session first.
However, if this don’t work, after some research….I found the following methods:


Method 1:


Open CMD with admin right, then —

A. Type “qwinsta /server:xxx.xxx.xxx.xxx” into the window, replacing “xxx.xxx.xxx.xxx” with the IP address of your server. When you hit “Enter,” a list of active remote-desktop connections will appear. Each session will have an ID number assigned to it.

B. Use the “rwinsta /server:xxx.xxx.xxx.xxx id” command, replacing “xxx.xxx.xxx.xxx” with the IP address of your server and “id” with the ID number of the session you want to end. When you hit “Enter,” Windows will end the selected session.


Method 2:


A. Go to CMD prompt and run “quser /server:YOUR_SERVER_NAME”, it will list all the remote connection.


B. Still in CMD prompt, run “logoff rdp-tcp#123 /server:YOUR_SERVER_NAME”(where 123 is the sessionname)