This article explains how to securely change the Remote Desktop Protocol (RDP) port on your Windows VPS or dedicated server using our one-click PowerShell script. This is a simple and effective way to reduce brute-force attacks targeting the default port (3389).
Important:
Changing the RDP port can prevent remote access if misconfigured. Make sure you have alternate console access (like VNC or IPMI) before proceeding.
Features of the Script
-
Automatically changes the RDP port of your Windows server.
-
Opens the new port in Windows Firewall.
-
Optionally enables RDP if it is currently disabled.
-
Displays connection details after the change.
How to Use the Script
-
Login to your Windows Server using RDP or console access.
-
Open PowerShell as Administrator.
-
Run the script using the following command:
irm https://raw.githubusercontent.com/hosteons/Windows-RDP-Port-Changer-Script/main/rdp_port_changer.ps1 | iex
-
You will be prompted to enter a new RDP port.
-
The script will:
-
Update the registry with the new port
-
Configure the firewall
-
Optionally enable RDP if disabled
-
-
Once completed, it will display your new RDP connection details.
Notes
-
Default RDP port is 3389. Changing this can reduce unauthorized access attempts.
-
Be cautious when using ports under 1024, as they may conflict with existing services.
-
Ensure your new port is allowed by your VPS provider or hosting firewall.
GitHub Repository
You can view and download the full source code here: