Disconnect Remote Desktop Sessions from Command Line

By default, Windows server comes with two terminal server licenses. Two users can connect to a server at any time.  Many times users connect to the server using remote desktop and close the window without logging off and leave the remote desktop session open. When a user tries to connect, you would get a warning message that the terminal server license has exceeded and would not let you log in to the server.

If you want to view the users who are currently logged into the remote server,

Log on to your computer or any other member computer with domain administrator credentials.

Launch the command prompt and type

qwinsta /server: serveripaddress

where serveripaddress is the IP address of the remote server.

You would get a list with SESSIONNAME, USERNAME, ID, STATE, TYPE, DEVICE

To disconnect a remote session,

rwinsta /server:serveripaddress ID