Config Server Firewall

PowerShell Command to Enable Remote Desktop in Windows

You can enable Remote Desktop (RDP) in Microsoft Windows using PowerShell. You just need to run the following two commands one after the other:

Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Value 0
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"

You can utilize these two PowerShell commands to enable Remote Desktop on Windows 10, Windows 11, and Windows Server.

The first command edits the necessary registry key to enable Remote Desktop functionality. The second command allows Remote Desktop connections through the Windows Firewall.

The two commands work together to enable Remote Desktop and open the necessary firewall ports.

If you want to disable Remote Desktop, run the following two commands:

Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Value 1
Disable-NetFirewallRule -DisplayGroup "Remote Desktop"