I was searching for a solution for this and found an option to log off the remote desktop users from another machine (in the same domain) through command line. The first step to achieve is to list the current log on session on the remote computer. For that we can use following command from the command prompt. Replace the xx.xx.xx.xxx with your server IP address.
C:\>quser /SERVER: xx.xx.xx.xxx
This will list the current log on session. Please find below screenshot. I have removed the IP address and log in name from the screenshot. You can see the session ID 0,1 and 2 for three available sessions. This is the ID which we will be using in our next step to log off user.
To log off session listed in the previous step, use the following command.Here I am trying to log off the session 0
C:\> logoff /SERVER:xx.xx.xx.xxx 0 /V
Now you will be able to do the remote desktop to the server.