Skip to main content

How to change Remote Desktop Protocol (RDP) port setting in Windows Server

This procedure comprises of several steps

1. Change the port number

2. Add the port to Windows Firewall

3. Toggle RDP services on/off

4. Reconfigure RackCorp VM Firewall to new port, if applicable

5. Port Scan to verify results.


In this example, we shall use a simple PowerShell script to enact the changes. changing RDP from 3389 to 13990 on windows server.

$portvalue = 13390

Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber" -Value $portvalue 

New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Profile 'Any' -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvalue 
New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Profile 'Any' -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue 

Once you have run this script, Toggle RDP in the windows remote desktop settings on and off

Use to verify that the applicable ports you are opening and closing come up as open or filtered