use New-NetFirewallRule for RDP and set UserAuthentication=1
New-NetFirewallRule with -Profile Any is more reliable than Enable-NetFirewallRule (predefined rules may not exist or be profile-scoped). Set UserAuthentication=1 (NLA) per standard RDP configuration. Settings take effect after reboot. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
84bcc9b66c
commit
af764989c1
1 changed files with 6 additions and 9 deletions
|
|
@ -97,19 +97,16 @@ in
|
|||
|
||||
${lib.optionalString enableRDP ''
|
||||
:: Enable RDP
|
||||
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
|
||||
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v UserAuthentication /t REG_DWORD /d 0 /f
|
||||
powershell -Command "Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections -Value 0"
|
||||
powershell -Command "Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name UserAuthentication -Value 1"
|
||||
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Lsa" /v LimitBlankPasswordUse /t REG_DWORD /d 0 /f
|
||||
:: Enable RDP firewall rules for all network profiles
|
||||
powershell -Command "Enable-NetFirewallRule -DisplayGroup 'Remote Desktop'"
|
||||
powershell -Command "Set-NetFirewallRule -DisplayGroup 'Remote Desktop' -Profile Any"
|
||||
:: Set all RDP services to auto-start via registry (sc config can fail silently)
|
||||
:: Create firewall rules for all profiles (New-NetFirewallRule is more reliable than Enable-NetFirewallRule)
|
||||
powershell -Command "New-NetFirewallRule -DisplayName 'RDP (TCP)' -Direction Inbound -Action Allow -Protocol TCP -LocalPort 3389 -RemoteAddress Any -Profile Any -Enabled True | Out-Null"
|
||||
powershell -Command "New-NetFirewallRule -DisplayName 'RDP (UDP)' -Direction Inbound -Action Allow -Protocol UDP -LocalPort 3389 -RemoteAddress Any -Profile Any -Enabled True | Out-Null"
|
||||
:: Set all RDP services to auto-start
|
||||
reg add "HKLM\SYSTEM\CurrentControlSet\Services\SessionEnv" /v Start /t REG_DWORD /d 2 /f
|
||||
reg add "HKLM\SYSTEM\CurrentControlSet\Services\UmRdpService" /v Start /t REG_DWORD /d 2 /f
|
||||
reg add "HKLM\SYSTEM\CurrentControlSet\Services\TermService" /v Start /t REG_DWORD /d 2 /f
|
||||
net start SessionEnv
|
||||
net start TermService
|
||||
net start UmRdpService
|
||||
''}
|
||||
|
||||
:: Clean up
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue