How to change the listening port for Remote Desktop
Summary
All current versions of Windows employ the remote desktop protocol, which is located on port 3389, to enable remote desktop services. If your computer has Remote Desktop enabled, it is waiting for connections on port 3389.
It is advised that you modify the RDP port by default in order to defend your system against script kiddies and bots.
You can change the listening port on Windows computers by modifying the registry.
Steps to change the Remote Desktop server port:
1] Type Regedit in the Search box and start the registry editor by clicking on the regedit editor icon.

2] Navigate to HKEY_LOCAL_MACHINE> SYSTEM> CurrentControlSet> Control> Terminal Server> WinStations> RDP-Tcp, in Registry Editor.

3] Click on RDP-Tcp, and you will see PortNumber on the right side of the window panel.
4] Now, Right-click on the PortNumber and select Modify.

5] Change the Base to Decimal and enter a new port between 1025 and 65535 that is not already in use.

6] Click OK and reboot.
The next time you use the Remote Desktop connection to connect to this computer, you have to input the new port. Make sure your firewall is configured to permit connections to the new port number if you use one.
PowerShell command to check the current port:
Get-ItemProperty -Path ‘HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp’ -name “PortNumber”
For Example:
PortNumber : 3389 PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations PSChildName : RDP-Tcp PSDrive : HKLM PSProvider : Microsoft.PowerShell.Core\Registry
You can also modify the RDP port by performing the PowerShell code below. In this command, the new port number provided is 3390.
$portvalue = 3390 Set-ItemProperty -Path ‘HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp’ -name “PortNumber” -Value $portvalue New-NetFirewallRule -DisplayName ‘RDPPORTLatest-TCP-In’ -Profile ‘Public’ -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvalue New-NetFirewallRule -DisplayName ‘RDPPORTLatest-UDP-In’ -Profile ‘Public’ -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue
And that’s how you change the listening port for the remote desktop on your computer.