Remote Desktop Gateway

On Windows Computer, the Remote Desktop is disabled by default. You need to enable it in order to make the computer is accessible remotely through Remote Desktop Protocol (RDP). In this article, I will show you how to enable Remote Desktop Protocol (RDP) remotely.

First, we need to connect to the computer/workstation you want to RDP-able using PowerShell Remote. In addition, you can use the psexec tool from Sysinternals.

Step 1. Connect to the computer

If you use PowerShell Remote, you can use Enter-PSSession cmdlet to connect to the computer.

Enter-PSSession -ComputerName <Remote Computer>

If you use PSExec tool. Download the app and drop it into your c:\ drive, you can run this command and get command line access for that remote box.

c:\psexec \\remote_machine_name cmd 

Step 2. Open firewall ports in Windows firewall

Once you connected to the remote computer, you can run this command to disable the firewall.

netsh advfirewall set currentprofile state off 

In addition, you can keep the windows firewall on and only allow Remote Desktop Protocol.

netsh advfirewall firewall set rule group=”remote desktop” new enable=Yes 

Step 3. Registry Changes to enable Remote Desktop

Using PSExec

If you use psexec, run this command to change the remote registry:

reg add “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server” /v fDenyTSConnections /t REG_DWORD /d 0 /f 

Using PowerShell Remote

If you use PowerShell Remote, you can run the command below on PowerShell.

Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name fDenyTSConnections -Value 0

Using Remote Registry

Open Registry Editor and click File->Connect Network Registry. Enter the name of your remote computer and connect to it. Navigate to HKEY_LOCAL_MACHINE > System > CurrentControlSet > Control > Terminal Server. Change the value of “fDenyTSConnections” to “0”

Remote Registry

Step 4. Connect

At this point, you can try to connect to the remote computer using Remote Desktop Protocol.