Logoff disconnected users on RDS server with powershell


When you want to manually logoff disconnected users from a Remote Desktop server, you can first query the server for those disconnected sessions and then logoff those sessions.

Logoff disconnected users on RDS server with powershell:

Or if the list is to long you can query the disconnected sessions:

This script queries the RDS broken for sessions and displays a nice (gridview) form. In this form you can select a user to logoff.



  • Ramses Murillo says:

    That is very nice and clean, I seem to need some help though. We have RDS deployed in our environment. I am using the powershell commands as shown below:

    Import-Module RemoteDesktop
    $server = ‘serverX01.contoso.com’ —–Obviously this is a fake name to protect the identity of our servers
    Get-RDUserSession -ConnectionBroker $Server

    and I am getting a message:
    “Get-RDUserSession : A Remote Desktop Services deployment does not exist on
    I have read a lot of articles that don’t see to offer a clean resolution on this issue. Do you have any ideas what could be the problem?

    Thank you!

  • I need a powershell a=command to only logoff disconnected users in one shot if 30 users are in my server 2012 R2 and 15 are stuck as disconnected do you have a command that will disconnect just the 15 at once ?


Leave a Reply

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