
Turning on Remote Desktop through Settings is easy when you're sitting at the machine. On a Server Core install, through a recovery console, in a deployment script, or on a remote computer you can't see, the command line is faster. This guide shows the exact commands to enable RDP with Command Prompt and PowerShell, open the firewall, keep Network Level Authentication on, enable it on a remote PC, and secure the server afterwards. They work on Windows 10, 11 and Windows Server 2016 through 2025.
Quick answer
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
netsh advfirewall firewall set rule group="remote desktop" new enable=Yes
Prerequisites
- Windows Pro, Enterprise, Education or Windows Server (Home editions can't host Remote Desktop).
- An elevated Command Prompt or PowerShell window (Run as administrator).
- An account with a password that's a member of Administrators or Remote Desktop Users.
Enable RDP with Command Prompt
- Allow Remote Desktop connections:
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f - Require Network Level Authentication (recommended):
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v UserAuthentication /t REG_DWORD /d 1 /f - Open the Windows Firewall rules for Remote Desktop:
On non-English Windows the group name is translated; use the PowerShell method below, which works in any language.netsh advfirewall firewall set rule group="remote desktop" new enable=Yes - Allow a non-admin user to connect:
net localgroup "Remote Desktop Users" alice /add
Enable RDP with PowerShell
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections -Value 0
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name UserAuthentication -Value 1
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
Add-LocalGroupMember -Group "Remote Desktop Users" -Member "alice"
If -DisplayGroup "Remote Desktop" doesn't match on a localized system, use Enable-NetFirewallRule -Name RemoteDesktop*.
On Windows Server Core: sconfig
Run sconfig and choose the Remote Desktop option, then enable it with NLA (more secure). It sets the same registry values and firewall rules.
Check that it worked
reg query "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections
netstat -an | findstr 3389
Get-NetFirewallRule -DisplayGroup "Remote Desktop" | Select DisplayName, Enabled
fDenyTSConnections should be 0x0, and port 3389 should show LISTENING. From another computer, test with Test-NetConnection SERVER_IP -Port 3389 or connect with mstsc /v:SERVER_IP.
Enable RDP on a remote computer
If you can reach the computer over the network but not by RDP:
- PowerShell remoting (if WinRM is enabled, as on Windows Server by default):
Invoke-Command -ComputerName SERVER01 -ScriptBlock { Set-ItemProperty 'HKLM:\System\CurrentControlSet\Control\Terminal Server' fDenyTSConnections 0 Enable-NetFirewallRule -DisplayGroup "Remote Desktop" } - PsExec from Microsoft Sysinternals, with admin rights on the target:
psexec \\SERVER01 reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f psexec \\SERVER01 netsh advfirewall firewall set rule group="remote desktop" new enable=Yes - Group Policy in a domain: Computer Configuration → Administrative Templates → Windows Components → Remote Desktop Services → Remote Desktop Session Host → Connections → Allow users to connect remotely by using Remote Desktop Services.
- VPS: use your provider's VNC/web console to run the commands locally.
Change the RDP port (optional)
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v PortNumber /t REG_DWORD /d 53389 /f
netsh advfirewall firewall add rule name="RDP 53389" dir=in action=allow protocol=TCP localport=53389
net stop TermService /y && net start TermService
Add the new firewall rule before restarting the service, and connect with mstsc /v:SERVER_IP:53389.
Secure Remote Desktop after enabling it
- Keep NLA on so users must authenticate before a session starts.
- Use long, unique passwords and an account lockout policy to stop password guessing.
- Restrict port 3389 (or your custom port) to known IP addresses in the firewall, or put RDP behind a VPN or Remote Desktop Gateway.
- Rename or disable the built-in Administrator account and use named admin accounts.
- Keep Windows updated; RDP vulnerabilities are patched through normal security updates.
Frequently asked questions
How do I enable Remote Desktop from CMD?
Set fDenyTSConnections to 0 with reg add, then enable the "remote desktop" firewall rule group with netsh.
What is the PowerShell command to enable RDP?
Set-ItemProperty on fDenyTSConnections = 0, then Enable-NetFirewallRule -DisplayGroup "Remote Desktop".
Can I enable RDP on a remote PC without logging in?
Yes, with PowerShell remoting, PsExec or Group Policy, as long as you have admin rights and network access to it.
Does enabling RDP from the command line require a restart?
No. The change applies immediately. Restarting the Remote Desktop service is only needed after changing the port.


