Enable Remote Desktop PowerShell: Setting Firewall Rules Too

Enabling Remote Desktop and Opening the Firewall Port with PowerShell Turning on Remote Desktop from the GUI is fine for a one-off machine, but if you’re setting up a server (especially Server Core, where there’s no GUI to click through) doing it via PowerShell is quicker and scriptable across multiple machines. First, enable Remote Desktop […]

Enable Windows Remote Desktop Protocol And Set Firewall Rules Using

Enabling Remote Desktop and Opening the Firewall Port with PowerShell

Turning on Remote Desktop from the GUI is fine for a one-off machine, but if you’re setting up a server (especially Server Core, where there’s no GUI to click through) doing it via PowerShell is quicker and scriptable across multiple machines.

First, enable Remote Desktop itself by flipping the fDenyTSConnections registry value:

Set-ItemProperty -Path 'HKLM:SystemCurrentControlSetControlTerminal Server' -Name "fDenyTSConnections" -Value 0

Then make sure the Windows Firewall rule group for Remote Desktop is enabled so the traffic is actually allowed through:

Enable-NetFirewallRule -DisplayGroup "Remote Desktop"

Run both from an elevated PowerShell session. Once complete, you should be able to connect over RDP immediately — no reboot required for either change. If you also want to require Network Level Authentication (recommended for anything internet-facing), that’s a separate property:

Set-ItemProperty -Path 'HKLM:SystemCurrentControlSetControlTerminal ServerWinStationsRDP-Tcp' -Name "UserAuthentication" -Value 1

Resources

🛠️

Gear We Recommend

Firewall rules are only half the story. Here’s the networking hardware we recommend for a properly segmented setup.

Browse our Networking Equipment picks on Amazon

As an Amazon Associate, TechyGeeksHome earns from qualifying purchases.


Discover more from TechyGeeksHome

Subscribe to get the latest posts sent to your email.

Andrew Armstrong

Andrew Armstrong is a UK-based IT professional with 26+ years of hands-on experience in Windows, Windows Server, SCCM/ConfigMgr, Active Directory, PowerShell, and enterprise infrastructure.

He founded TechyGeeksHome in 2010 and has published over 1,500 practical guides covering real-world IT problems and solutions. When not solving IT problems,

Andrew develops free Windows utilities including Ultimate Settings Panel, which has been downloaded over 850,000 times.

12 thoughts on “Enable Remote Desktop PowerShell: Setting Firewall Rules Too

  1. ” Enable-NetFirewallRule -DisplayGroup “Remote Desktop” ”

    How enable this is use only domain?

    1. You could use a Get and then Enable method. So you could try something like this:

      Get-NetFirewallRule | Where {$.DisplayGroup -eq “Remote Desktop” -and $.Profile -eq “Domain”} | Enable-NetFirewallRule

  2. ” Enable-NetFirewallRule -DisplayGroup “Remote Desktop” ”

    How enable this is use only domain?

    1. You could use a Get and then Enable method. So you could try something like this:

      Get-NetFirewallRule | Where {$_.DisplayGroup -eq “Remote Desktop” -and $_.Profile -eq “Domain”} | Enable-NetFirewallRule

  3. ” Enable-NetFirewallRule -DisplayGroup “Remote Desktop” ”

    How enable this is use only domain?

    1. You could use a Get and then Enable method. So you could try something like this:

      Get-NetFirewallRule | Where {$_.DisplayGroup -eq “Remote Desktop” -and $_.Profile -eq “Domain”} | Enable-NetFirewallRule

Comments are closed.