Created
July 14, 2025 16:05
-
-
Save boranbar/843d6fdf68f6a73b92994663e9db1ff3 to your computer and use it in GitHub Desktop.
PowerShell script to change the default Remote Desktop Protocol (RDP) port on Windows, remove flood protection limits, and automatically configure the Windows Firewall.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Yeni RDP Port Numarası (gerekirse bu değeri değiştirin) | |
| $NewRdpPort = 42500 | |
| Write-Host "🔧 RDP ayarları yapılandırılıyor..." -ForegroundColor Cyan | |
| # 1. RDP Flood limitlerini kaldır | |
| Write-Host "⚙️ Flood limit ayarları kaldırılıyor..." -ForegroundColor Yellow | |
| New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "MaxOutstandingConnections" -Value 0 -PropertyType DWord -Force | Out-Null | |
| New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "MaxConnectionTimeOut" -Value 0 -PropertyType DWord -Force | Out-Null | |
| # 2. RDP Portunu değiştir | |
| Write-Host "📡 RDP portu $NewRdpPort olarak ayarlanıyor..." -ForegroundColor Yellow | |
| Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name "PortNumber" -Value $NewRdpPort | |
| # 3. Yeni port için firewall kuralı oluştur | |
| Write-Host "🛡️ Yeni firewall kuralı ekleniyor (Port $NewRdpPort)..." -ForegroundColor Yellow | |
| New-NetFirewallRule -DisplayName "RDP Custom Port $NewRdpPort" -Direction Inbound -Protocol TCP -LocalPort $NewRdpPort -Action Allow | |
| # 4. Hizmeti yeniden başlat | |
| Write-Host "🔄 RDP servisi yeniden başlatılıyor..." -ForegroundColor Cyan | |
| Stop-Service -Name TermService -Force | |
| Start-Service -Name TermService | |
| Write-Host "✅ RDP yapılandırması tamamlandı! Lütfen yeni port üzerinden bağlantı kurun." -ForegroundColor Green |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
RDP Port Change Script - Usage Instructions
This guide explains how to run the
rdp_change.ps1script to change the default RDP port and configure firewall rules on Windows.📥 1. Save the Script
rdp_change.ps1script.🧑💻 2. Run the Script with Administrator Privileges
$NewRdpPort = 42500If you want to use a different port number, you must manually edit this line before running the script.
Make sure the new port is not already in use and that it is allowed through your firewall or network policies.
After changing the port, you will need to connect to your machine using the new format:
your-ip:NEW_PORTFor example, if you changed the port to 3399, you would connect like this:
192.168.1.10:3399