LLI Wiki — My Digital Knowledge Base

Managing RDP sessions remotely on Windows

Commands to list and reset Remote Desktop sessions on a server and to enable RDP remotely with PowerShell.

This page groups common commands to list, close and reset Remote Desktop (RDP) sessions on a Windows server, and to enable RDP remotely with PowerShell.

Listing and resetting sessions

Command Role
qwinsta (alias of query session) Shows the sessions open on a server.
rwinsta (alias of reset session) Closes a session by its ID.
qwinsta /server:SERVER01
query session /server:SERVER01
reset session <ID> /server:SERVER01
rwinsta <ID> /server:SERVER01

Authenticated connection to a server

net use \\servername_or_IP /USER:username

Enabling RDP remotely

Invoke-Command -ComputerName SERVER01 -ScriptBlock {
    Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Value 0
}

Invoke-Command -ComputerName SERVER01 -ScriptBlock {
    Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
}

Notes

Mastodon LLIMastodon SocialFosstodon