Code: Select all
$portvalue = 3388
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber" -Value $portvalue
New-NetFirewallRule -DisplayName 'RDPNEW-TCP-In' -Profile 'Public' -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvalue
New-NetFirewallRule -DisplayName 'RDPNEW-UDP-In' -Profile 'Public' -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue
After reboot connect using Remote Desktop client ServerIP:3388
If you are using Remote Desktop Manger, you need set port on connection properties [Connection Settings]
Note: some internet providers might block Remote Desktop connection if port is changed.