Categories: Windows

Windows – Killing remotely hanging RDP session

You can't log in to RDP session on Windows 2003/Windows 2003 R2 server because you get a message that all sessions are taken, or you simply want to cleanup your RDP sessions from Windows 2008-2012R2 servers.

🛠️ Solution

(Optional) Gain enough privilege to kill RDP connection on the server. This step is optional if you're already logged in with credentials that are valid for multiple sessions (such as domain environment)

net use servername_or_IP /USER:username “password“

List the connection to a particular server and get session ID.

query session /server:servername

Reset the session which you don’t need using ID of the session

reset session ID /server:servername_or_IP

📌 Example

query session /server:TEST2003
SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
console                                     0  Conn    wdcon
rdp-tcp                                 65536  Listen  rdpwd
rdp-tcp#32        server-userid1            1  Active  rdpwd
rdp-tcp#33        server-userid2            2  Active  rdpwd

This post was last modified on June 6, 2025 19:07

Przemyslaw Klys

System Architect with over 14 years of experience in the IT field. Skilled, among others, in Active Directory, Microsoft Exchange and Office 365. Profoundly interested in PowerShell. Software geek.

Share
Published by
Przemyslaw Klys

Recent Posts

Supercharging Your Network Diagnostics with Globalping for NET

Ever wondered how to run network diagnostics like Ping, Traceroute, or DNS queries from probes…

2 weeks ago

Automating Network Diagnostics with Globalping PowerShell Module

Are you tired of manually running network diagnostics like Ping, Traceroute, or DNS queries? The…

2 weeks ago

Enhanced Dashboards with PSWriteHTML – Introducing InfoCards and Density Options

Discover new features in the PSWriteHTML PowerShell module – including New-HTMLInfoCard, improved layout controls with…

3 weeks ago

Mastering Active Directory Hygiene: Automating SIDHistory Cleanup with CleanupMonster

Security Identifier (SID) History is a useful mechanism in Active Directory (AD) migrations. It allows…

3 weeks ago

Upgrade Azure Active Directory Connect fails with unexpected error

Today, I made the decision to upgrade my test environment and update the version of…

3 weeks ago

Mastering Active Directory Hygiene: Automating Stale Computer Cleanup with CleanupMonster

Have you ever looked at your Active Directory and wondered, "Why do I still have…

3 weeks ago