board logo
Posted by: DogMan - 07 July 2026 11:03:52
After reboot server is not listening for RDP for remote admin anymore - how can I reawaken with powershell remotely?

Posted by: sirclesadmin - 07 July 2026 11:05:23

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

Posted by: sirclesadmin - 07 July 2026 14:28:17

Good catch! The issue isn't a missing parenthesis, but a classic PowerShell quoting trap: inside the script block, the single quotes around the registry paths 'HKLM:\...' can sometimes conflict with how the block is parsed or passed over the network, depending on how you copy-pasted it.

Here is the exact code cleaned up into a single, cohesive script using standard double quotes for consistency. I have also added an automated check at the end so it explicitly tells you if it succeeded.

Just change "YOUR_SERVER_NAME_OR_IP" on line 2 and run the whole thing:

# Define your target server here
$TargetServer = "YOUR_SERVER_NAME_OR_IP"

Write-Host "Connecting to $TargetServer to repair RDP configurations..." -ForegroundColor Cyan

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. Temporarily disable Network Level Authentication (NLA) to bypass credential blocks
    Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name "UserAuthentication" -Value 0

    # 5. Ensure the Firewall is wide open for RDP
    Enable-NetFirewallRule -DisplayGroup "Remote Desktop"

    # Quick validation check to echo back to your local console
    $rdpState = Get-ItemPropertyValue -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections"
    if ($rdpState -eq 0) {
        Write-Host "SUCCESS: Target registry updated. RDP is now set to ALLOW connections." -ForegroundColor Green
    } else {
        Write-Host "WARNING: Registry value did not update properly." -ForegroundColor Yellow
    }
}

Posted by: andrewt2m - 07 July 2026 14:33:37
It was because the DCs some up later in our case: [code=markup]Log Name: System Source: Microsoft-Windows-TerminalServices-RemoteConnectionManager Date: 06/07/2026 23:32:26 Event ID: 1067 Task Category: None Level: Warning Keywords: Classic User: N/A Computer: SRV2.domain.local Description: The RD Session Host server cannot register 'TERMSRV' Service Principal Name to be used for server authentication. The following error occured: The specified domain either does not exist or could not be contacted. . Event Xml: <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="Microsoft-Windows-TerminalServices-RemoteConnectionManager" Guid="{C76BAA63-AE81-421C-B425-340B4B24157F}" EventSourceName="TermService" /> <EventID Qualifiers="49152">1067</EventID> <Version>0</Version> <Level>3</Level> <Task>0</Task> <Opcode>0</Opcode> <Keywords>0x80000000000000</Keywords> <TimeCreated SystemTime="2026-07-06T22:32:26.5638363Z" /> <EventRecordID>421422</EventRecordID> <Correlation /> <Execution ProcessID="0" ThreadID="0" /> <Channel>System</Channel> <Computer>SRV2.domain.local</Computer> <Security /> </System> <EventData> <Data>The specified domain either does not exist or could not be contacted. </Data> </EventData> </Event>[/code]