List and kill remote desktop connections

Today I marking the official start of my new blog series entitled quick tips. For this series I will focus on simple things that developers might find handy; from scripts, to commands, hot-keys and other tips that, maybe you already know, maybe not. Most of the posts from this series, will be direct, quick and simple. Personally, I just want to share the notes I have been gathering though the years. For my first quick tip post, I will show how you can list all remote desktop connections, and kill a particular session.

Sometimes you might encounter the following error when trying to establish a remote desktop connection: ” The terminal server has exceeded the maximum number of allowed connections”. This happens because there’s a maximum limit of allowed remote connections. On top of that, maybe somebody forgot to logoff their remote desktop connection, and their inactive session might occupying a spot that you could use. maximum terminal connections error

Let’s begin by opening the command prompt (or PowerShell) using: [Win] + [r]; type cmd (or powershell) and press [enter]

Now we are going to use qwinsta to (paraphrasing documentation) “ Display information about Remote Desktop Services sessions.”. If you use the command without any additional arguments, information about your local computer sessions will be display. However, most likely you want to target a remote computer; to do that simply enter the server name, or machine IP, using /SERVER: argument. Example qwinsta /SERVER:mywebserver or qwinsta /SERVER:192.168.1.15 qwinsta screenshot

To disconnect, or reset a particular session, just use rwinsta and supply the server name and the session Id you want to reset. Session Ids are display on qwinsta resulting output. Example rwinsta /SERVER:mywebserver 70

For more information about this two command, please take a look at their TechNet documentation pages: qwinsta ; rwinsta.