Advertisement
willysec_id

RDPSecurity.ps1

Oct 22nd, 2024
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 0.49 KB | Source Code | 0 0
  1. # Set the new RDP port (replace 13389 with your desired port number)
  2. $newPort = 13389
  3. Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name "PortNumber" -Value $newPort -Type DWord
  4.  
  5. # Allow the new port through the firewall
  6. New-NetFirewallRule -DisplayName "Allow RDP on Port $newPort" -Direction Inbound -Protocol TCP -LocalPort $newPort -Action Allow
  7.  
  8. # Restart the Remote Desktop service to apply changes
  9. Restart-Service TermService -Force
  10.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement