If the server is still pingable and responsive on the network but just rejecting RDP connections, you can use PowerShell from your local machine to check the registry, fix the RDP service, and flip the switch to allow connections again.
Here is how to get it back online remotely, assuming you have administrative rights over the network.
Step 1: Establish a Remote Session
Open PowerShell as an Administrator on your local machine and target the remote server.
$TargetServer = "YOUR_SERVER_NAME_OR_IP"
Step 2: Fix the RDP Service and Registry Settings
Run this block to connect via WinRM, ensure the Remote Desktop services are actually running, and force the registry to allow remote connections.
Invoke-Command -ComputerName $TargetServer -ScriptBlock {
# 1. Force the RDP service to start and set it to automatic
Set-Service -Name "TermService" -StartupType Automatic
Start-Service -Name "TermService" -WarningAction SilentlyContinue
# 2. Update the registry to allow Remote Desktop connections (0 = Allow, 1 = Deny)
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name "fDenyTSConnections" -Value 0
# 3. Enable Remote Administration in the RPC settings
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name "TSAppCompat" -Value 0
# 4. Optional: If Network Level Authentication (NLA) is blocking you, temporarily disable it
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name "UserAuthentication" -Value 0
}
Step 3: Check the Windows Firewall
If the registry was already fine, a firewall profile might have flipped to "Public" on reboot, blocking port 3389. Run this to explicitly open the gates for RDP:
Invoke-Command -ComputerName $TargetServer -ScriptBlock {
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
}
What if WinRM / PSSession is also blocked?
If Invoke-Command fails because remote management is completely locked down, you can fall back to targeting the remote registry directly using standard .NET classes over the network:
# Open the remote registry hive
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $TargetServer)
$key = $reg.OpenSubKey("System\CurrentControlSet\Control\Terminal Server", $true)
# Flip the denial bit to 0
$key.SetValue("fDenyTSConnections", 0, [Microsoft.Win32.RegistryValueKind]::DWord)
# Close handles
$key.Close()
$reg.Close()
# Force a remote reboot using WMI to apply changes and clear hung threads
Restart-Computer -ComputerName $TargetServer -Force