Created
June 28, 2026 13:31
-
-
Save vtvh/85c4d86e7e8acd398f355cacad2f0b38 to your computer and use it in GitHub Desktop.
This script modifies the registry to allow connections, configures the firewall, and ensures the Remote Desktop Service (TermService) is set to Automatic so it starts every time the computer boots up.
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
| <# | |
| .SYNOPSIS | |
| Configures a Windows computer as an RDP Host to automatically accept connections on boot. | |
| .DESCRIPTION | |
| This script enables RDP, configures the Windows Firewall, and sets the | |
| Remote Desktop Service (TermService) to start automatically. | |
| Must be run as Administrator. | |
| #> | |
| # 1. Verify Administrator privileges (Required for Registry, Firewall, and Services) | |
| $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) | |
| if (-not $isAdmin) { | |
| Write-Warning "Administrator rights are required." | |
| Write-Warning "Please close this window, open PowerShell as Administrator, and run the script again." | |
| Exit | |
| } | |
| Write-Host "Configuring Windows Host for Remote Desktop..." -ForegroundColor Cyan | |
| try { | |
| # 2. Enable Remote Desktop connections in the Registry | |
| # Setting fDenyTSConnections to 0 tells Windows to accept incoming connections | |
| Write-Host "-> Allowing RDP connections in the registry..." | |
| Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name "fDenyTSConnections" -Value 0 -ErrorAction Stop | |
| # 3. Enable Network Level Authentication (NLA) for security (Recommended standard) | |
| # Setting UserAuthentication to 1 prevents unauthenticated session setup | |
| Write-Host "-> Enforcing Network Level Authentication (NLA)..." | |
| Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name "UserAuthentication" -Value 1 -ErrorAction Stop | |
| # 4. Open Windows Firewall for Remote Desktop traffic | |
| # Enables the built-in firewall rules for the "Remote Desktop" group | |
| Write-Host "-> Allowing Remote Desktop through Windows Firewall..." | |
| Enable-NetFirewallRule -DisplayGroup "Remote Desktop" -ErrorAction Stop | |
| # 5. Configure the service to start automatically on boot | |
| # This fulfills the requirement to have it accessible every time the PC restarts | |
| Write-Host "-> Configuring TermService to start automatically on boot..." | |
| Set-Service -Name "TermService" -StartupType Automatic -ErrorAction Stop | |
| # 6. Start the service immediately | |
| # This allows you to connect right now without needing to reboot first | |
| Write-Host "-> Starting the Remote Desktop Service..." | |
| Start-Service -Name "TermService" -ErrorAction Stop | |
| Write-Host "Success! The host is fully configured and will accept RDP connections automatically on every boot." -ForegroundColor Green | |
| } | |
| catch { | |
| Write-Error "Configuration failed: $_" | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
some fix
You hit the nail on the head with "show login and password." What you are describing is controlled by Network Level Authentication (NLA).
In the setup script I provided earlier, we intentionally turned NLA on for security. When NLA is active, Windows forces your client to authenticate securely in the background before it establishes the visual session. If credentials fail or get tangled, it just drops the connection entirely.
If we turn NLA off, the client will connect immediately and show you the actual Windows lock screen, allowing you to type your password directly into the remote machine. This is a fantastic way to bypass early authentication drops.
Here is the exact troubleshooting sequence to knock this out on the Host computer.
1. Disable NLA to Force the Login Screen
Run this in PowerShell as Administrator on the Host to turn off NLA and restart the service:
Try connecting from the client again. If you see the Windows login screen, your network is perfect, and the issue was credential handshaking.
2. Verify User Permissions
Even if the port is open and the password is right, Windows will reject the connection if the specific user account is not authorized for remote access. (Administrators have this right by default, but standard accounts do not).
Run this in PowerShell as Administrator on the Host (replace YourUsername with the exact Windows account name you are trying to log into):
(If it throws an error saying the user is already in the group, then permissions are fine).
3. Check for Third-Party Interference
Since we know the network is Private and Windows Firewall is open, the last invisible wall is usually third-party security software. If you have Norton, McAfee, Bitdefender, or Kaspersky installed on the Host, their custom firewalls will actively block port 3389 even if Windows Firewall says it is allowed. You will need to temporarily pause the third-party firewall to test.
If disabling NLA still doesn't let you through, what exact error message is the RDP client throwing when the connection fails (e.g., "Remote Desktop can't connect to the remote computer", "An authentication error has occurred", etc.)?