管理员运行powershell
修改端口
$portvalue = 6666
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber" -Value $portvalue
New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Profile 'Public' -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvalue
New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Profile 'Public' -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue
![图片[1]-命令更改win远程桌面端口-云计算运维](https://blog.ossq.cn/wp-content/uploads/2024/03/1-1.png)
查看端口
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber"
![图片[2]-命令更改win远程桌面端口-云计算运维](https://blog.ossq.cn/wp-content/uploads/2024/03/2-1.png)
重启远程桌面服务使更改生效
net stop TermService
net start TermService
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END










