How to Change Your RDP Port Using PowerShell | Secure Your Windows VPS

  • Saturday, 30th May, 2026
  • 05:26am

Is your Windows VPS being attacked on the default RDP port 3389? In this video, I'll show you exactly how to change your RDP port in just seconds using a simple PowerShell script — no technical experience needed!

The default Remote Desktop Protocol (RDP) port 3389 is one of the most targeted ports by hackers, bots, and brute-force attacks. Changing it to a custom port is one of the easiest and most effective ways to secure your Windows VPS or dedicated server.

─────────────────────────────────────

WHAT YOU'LL LEARN IN THIS ARTICLE

─────────────────────────────────────

✅ How to open PowerShell as Administrator

✅ How to change RDP port using a single one-liner command

✅ How to allow the new port through Windows Firewall automatically

✅ How to reconnect to your VPS using the new custom port

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

VIDEO GUIDE - WATCH BEFORE YOU START

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

We have prepared a step-by-step video tutorial to make this process as easy as possible for you.

▶ Watch Here: https://youtu.be/v9KGNlthPhI

─────────────────────────────────────

EASIEST METHOD — ONE COMMAND ONLY

─────────────────────────────────────

Just open PowerShell as Administrator and run this single command:

irm http://directdownload.link/set_custom_rdp_port.ps1 | iex

This will automatically:

  • Bypass execution policy for the session

  • Change your RDP port to 1886 (edit the script to use your preferred port)

  • Add firewall rules for both Public & Private profiles (TCP & UDP)

  • Restart your server to apply all changes

─────────────────────────────────────

MANUAL POWERSHELL SCRIPT

─────────────────────────────────────

Prefer to run it manually? Copy and paste this into PowerShell (Admin):

Set-ExecutionPolicy Bypass -Scope Process -Force

$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', 'Private' -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvalue

New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Profile 'Public', 'Private' -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue

shutdown /r /t 60 /c "RDP Port change applied. Server will restart in 60 seconds."

 

Replace 3390 with any port number of your choice (recommended range: 1024–65535)

─────────────────────────────────────

⚠️ IMPORTANT NOTE

─────────────────────────────────────

After the server restarts, connect to your VPS using the new port format:

YOUR-IP:YOURCUSTOMPORT (e.g., 123.456.789.0:1886)

Make sure to note down your new port number before running the script!

« Back