Last active
November 10, 2022 17:24
-
-
Save Ran-Xing/48772568b0ae15738766b25a8b014495 to your computer and use it in GitHub Desktop.
Change Remote Desktop Port
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
$portvalue = 33891 | |
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber" -Value $portvalue | |
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp' -name "PortNumber" -Value $portvalue | |
New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Program "%SystemRoot%\system32\svchost.exe" -Profile Any -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvalue | |
New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Program "%SystemRoot%\system32\svchost.exe" -Profile Any -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue | |
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber" | |
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp' -name "PortNumber" | |
net stop termservice | |
y | |
net start termservice |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment