Last active
October 31, 2026 17:16
-
-
Save mickert/6afa764fa1307caf3ab590847b505e32 to your computer and use it in GitHub Desktop.
mitigation workflow for the September 2026 Cumulative Update RDP regression affecting Remote Desktop Services (TermService, RdpCoreTS transport pipeline, graphics teardown, and session handshake stability).
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
| # ================================================================================================== | |
| # Script Name : Invoke-RDPRegressionMitigation-For-2026-09-CU.ps1 | |
| # Version : 1.2.1 | |
| # Author : Michel Sijmons | |
| # License : Apache 2.0 | |
| # CanonicalURL: https://gists.mickert.dev/6afa764fa1307caf3ab590847b505e32#file-invoke-rdpregressionmitigation-for-2026-09-cu-ps1 | |
| # | |
| # Purpose : | |
| # Unified detection and mitigation workflow for the September 2026 Cumulative Update RDP regression | |
| # affecting Remote Desktop Services (TermService, RdpCoreTS transport pipeline, graphics teardown, | |
| # and session handshake stability). | |
| # | |
| # Special thanks to Fixitect for documenting RDP regression indicators used in this script: | |
| # - https://fixitect.com/ | |
| # - https://fixitect.com/kb/rdp-black-screen-sep-2026/ | |
| # | |
| # Additional thanks to Reddit user u/lesiromanu for early research into RDP regression behavior: | |
| # - https://www.reddit.com/user/lesiromanu/ | |
| # - https://www.reddit.com/r/sysadmin/comments/1wap96b/comment/p8wqgzy/ | |
| # | |
| # Description : | |
| # This script performs: | |
| # - High-speed rolling 24-hour event log scanning to prevent deep parsing execution hangs. | |
| # - Detection of RDP handshake timeout (Event 20498). | |
| # - Detection of UDP transport deadlock (Disconnect Reason 4407). | |
| # - Detection of WDDM graphics pipeline deadlocks (Events 101, 103, 227). | |
| # - Severity classification (OK, CRITICAL). | |
| # - Multi-tier OS-aware mitigation deployment pathing (Server 2019 vs 2022 vs 2025). | |
| # - Mitigation via TCP-only fallback (fSelectTransport = 1). | |
| # - Mitigation via URCP rate control disable (UseURCP = 0). | |
| # - Optional WDDM fallback (fEnableWddmDriver = 0) block-guarded on Server 2025+. | |
| # - Optional switches: | |
| # -ForceTcpOnly : Force TCP-only mitigation (fSelectTransport = 1). | |
| # -ForceWddmDisable : Force WDDM disable mitigation (fEnableWddmDriver = 0). | |
| # Automatically ignored on Windows Server 2025+ due to XDDM removal. | |
| # -ForceAudioDisable : Force audio redirection disable mitigation (fDisableAudioRedirection = 1) | |
| # -NoRestartRDS : Skip the TermService restart pipeline. | |
| # -CheckOnly : Perform full detection and severity classification without applying any mitigation. | |
| # -LogLookbackHours : Override the event log lookback window (default: 24 hours). | |
| # - State-Aware component restart auditing (UmRdpService, SessionEnv footprint tracking). | |
| # - Resilient 30-second passive observation wait loop to prevent aggressive process drops. | |
| # - Final ASCII-only summary report for RMM and automation pipelines. | |
| # | |
| # Notes : | |
| # - This script does NOT perform rollback of the 2026-09 CU. | |
| # - ASCII-only output for compatibility with RMM platforms and log parsers. | |
| # - Safe for production RDS environments (Server 2016 through Server 2025). | |
| # - Designed to prevent or mitigate the RDP deadlock states observed after the 2026-09 CU. | |
| # | |
| # Requirements : | |
| # - Run as Administrator | |
| # - PowerShell 5.1 or later | |
| # | |
| # Registry Changes Applied by This Script : | |
| # | |
| # 1. TCP-only Transport Fallback | |
| # Path : HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services | |
| # Value : fSelectTransport (DWORD) = 1 | |
| # | |
| # Purpose: | |
| # Disables UDP transport for RDP and forces TCP-only mode. This resolves the RDP transport | |
| # deadlock associated with Disconnect Reason 4407 and Event 20498 handshake timeouts. | |
| # | |
| # 2. Universal Rate Control Protocol (URCP) Throttling Disable | |
| # Path : HKLM\SOFTWARE\Microsoft\Terminal Server Client | |
| # Value : UseURCP (DWORD) = 0 | |
| # | |
| # Purpose: | |
| # Disables URCP network congestion adjustments. Applied alongside TCP-only on Server 2022 | |
| # to bypass heavy software rasterization performance penalties while resolving transport deadlocks. | |
| # | |
| # 3. Optional WDDM Fallback (disabled unless triggered or forced) | |
| # Path : HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services | |
| # Value : fEnableWddmDriver (DWORD) = 0 | |
| # | |
| # Purpose: | |
| # Forces RDP to use the legacy XDDM-style graphics pipeline instead of WDDM. This reduces | |
| # graphics teardown complexity and prevents instability on Server 2019 hosts showing WDDM | |
| # deadlock indicators (Events 101, 103 without 4407, or Event 227). Automatically skipped | |
| # on Server 2025+ due to modern kernel structural deprecation. | |
| # | |
| # ================================================================================================== | |
| # DISCLAIMER & LICENSE | |
| # ================================================================================================== | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at: | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| # | |
| # DISCLAIMER: | |
| # This script is provided "as-is" without any warranties or guarantees. | |
| # Use at your own risk. The author assumes no liability for any damages, | |
| # data loss, misconfiguration, or operational impact resulting from the | |
| # use of this script. Always test in a controlled environment before | |
| # deploying to production. | |
| # | |
| # ================================================================================================== | |
| # COPYRIGHT | |
| # ================================================================================================== | |
| # Copyright (c) 2026 Michel Sijmons - https://mickert.dev | |
| # All rights reserved. | |
| # ================================================================================================== | |
| param( | |
| [switch]$ForceWddmDisable, | |
| [switch]$ForceTcpOnly, | |
| [switch]$ForceAudioDisable, | |
| [switch]$CheckOnly, | |
| [switch]$NoRestartRDS, | |
| [int]$LogLookbackHours = 24 | |
| ) | |
| Write-Output "=== Unified RDP Regression Workflow For 2026-09 CU Started ===" | |
| # ------------------------------------------------------------ | |
| # Initialize report object | |
| # ------------------------------------------------------------ | |
| $Report = [ordered]@{ | |
| CheckOnly = $CheckOnly | |
| Event20498 = $false | |
| Udp4407 = $false | |
| GraphicsDeadlock = $false | |
| TermServiceStatus = $null | |
| TermServiceStartType = $null | |
| RdpCoreTSReadable = $false | |
| Severity = "UNKNOWN" | |
| TcpOnlyApplied = $false | |
| WddmApplied = $false | |
| UrcpApplied = $false | |
| AudioDisableApplied = $false | |
| MitigationApplied = $false | |
| TermServiceRestarted = $false | |
| } | |
| # ------------------------------------------------------------ | |
| # [1] Check TermService status | |
| # ------------------------------------------------------------ | |
| Write-Output "[1] Checking TermService status..." | |
| try { | |
| $svc = Get-Service -Name TermService -ErrorAction Stop | |
| $Report.TermServiceStatus = $svc.Status | |
| $Report.TermServiceStartType = $svc.StartType | |
| Write-Output "TermService Status: $($svc.Status)" | |
| Write-Output "TermService StartType: $($svc.StartType)" | |
| } | |
| catch { | |
| Write-Output "*** ERROR: TermService not found. ***" | |
| } | |
| # ------------------------------------------------------------ | |
| # [2] Check RDP session state | |
| # ------------------------------------------------------------ | |
| Write-Output "" | |
| Write-Output "[2] Checking RDP session state (qwinsta)..." | |
| qwinsta | |
| # Establish a trailing 24-hour lookback window to prevent deep log parsing hangs | |
| $LogLookbackWindow = if ($LogLookbackHours) { | |
| (Get-Date).AddHours(-1 * [Math]::Abs($LogLookbackHours)) | |
| } else { | |
| (Get-Date).AddHours(-24) | |
| } | |
| # ------------------------------------------------------------ | |
| # [3] Detect Event 20498 (RDP handshake timeout) | |
| # ------------------------------------------------------------ | |
| Write-Output "" | |
| Write-Output "[3] Checking for Event 20498 (RDP handshake timeout) within the last 24h..." | |
| $evt20498 = Get-WinEvent -FilterHashtable @{ | |
| LogName = "Microsoft-Windows-TerminalServices-RemoteConnectionManager/Admin" | |
| Id = 20498 | |
| StartTime = $LogLookbackWindow | |
| } -ErrorAction SilentlyContinue | |
| if ($evt20498) { | |
| Write-Output "Event 20498 detected." | |
| $Report.Event20498 = $true | |
| } else { | |
| Write-Output "No Event 20498 detected." | |
| } | |
| # ------------------------------------------------------------ | |
| # [4] Detect UDP disconnect reason 4407 | |
| # ------------------------------------------------------------ | |
| Write-Output "" | |
| Write-Output "[4] Checking for UDP disconnect reason 4407 within the last 24h..." | |
| $evt4407 = Get-WinEvent -FilterHashtable @{ | |
| LogName = "Microsoft-Windows-RemoteDesktopServices-RdpCoreTS/Operational" | |
| Id = 103 | |
| StartTime = $LogLookbackWindow | |
| } -ErrorAction SilentlyContinue | Where-Object { $_.Message -like "*4407*" } | |
| if ($evt4407) { | |
| Write-Output "UDP disconnect reason 4407 detected." | |
| $Report.Udp4407 = $true | |
| } else { | |
| Write-Output "No UDP 4407 disconnects detected." | |
| } | |
| # ------------------------------------------------------------ | |
| # [5] Detect WDDM graphics deadlocks | |
| # ------------------------------------------------------------ | |
| Write-Output "" | |
| Write-Output "[5] Checking for WDDM graphics pipeline deadlocks within the last 24h..." | |
| $gfxEvents = Get-WinEvent -FilterHashtable @{ | |
| LogName = "Microsoft-Windows-RemoteDesktopServices-RdpCoreTS/Operational" | |
| Id = 101, 103, 227 | |
| StartTime = $LogLookbackWindow | |
| } -ErrorAction SilentlyContinue | |
| if ($gfxEvents) { | |
| foreach ($evt in $gfxEvents) { | |
| if ($evt.Id -eq 227) { $Report.GraphicsDeadlock = $true } | |
| if ($evt.Id -eq 101) { $Report.GraphicsDeadlock = $true } | |
| if ($evt.Id -eq 103 -and $evt.Message -notlike "*4407*") { $Report.GraphicsDeadlock = $true } | |
| } | |
| } | |
| if ($Report.GraphicsDeadlock) { | |
| Write-Output "WDDM graphics deadlock indicators detected." | |
| } else { | |
| Write-Output "No WDDM graphics deadlock indicators found." | |
| } | |
| # ------------------------------------------------------------ | |
| # [6] Severity classification | |
| # ------------------------------------------------------------ | |
| Write-Output "" | |
| Write-Output "[6] Severity Classification..." | |
| if ($Report.Udp4407 -or $Report.Event20498 -or $Report.GraphicsDeadlock) { | |
| $Report.Severity = "CRITICAL" | |
| Write-Output "Severity: CRITICAL" | |
| } else { | |
| $Report.Severity = "OK" | |
| Write-Output "Severity: OK" | |
| } | |
| # ------------------------------------------------------------ | |
| # [7] Mitigation Modules | |
| # ------------------------------------------------------------ | |
| function Apply-WddmDisable { | |
| Write-Output "[7A] Applying WDDM disable mitigation (fEnableWddmDriver = 0)..." | |
| try { | |
| New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" -Force | Out-Null | |
| Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" ` | |
| -Name "fEnableWddmDriver" -Value 0 -Type DWord -Force | |
| Write-Output "WDDM disable policy applied successfully." | |
| $Report.WddmApplied = $true | |
| } | |
| catch { | |
| Write-Output "*** ERROR: Failed to apply WDDM disable policy. ***" | |
| Write-Output $_ | |
| $Report.WddmApplied = $false | |
| } | |
| } | |
| function Apply-TcpOnly { | |
| Write-Output "[7B] Applying TCP-only RDP transport mitigation (fSelectTransport = 1)..." | |
| try { | |
| New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" -Force | Out-Null | |
| Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" ` | |
| -Name "fSelectTransport" -Value 1 -Type DWord -Force | |
| Write-Output "TCP-only transport policy applied successfully." | |
| $Report.TcpOnlyApplied = $true | |
| } | |
| catch { | |
| Write-Output "*** ERROR: Failed to apply TCP-only transport policy. ***" | |
| Write-Output $_ | |
| $Report.TcpOnlyApplied = $false | |
| } | |
| } | |
| function Apply-UrcpDisable { | |
| Write-Output "[7C] Applying URCP disable mitigation (UseURCP = 0)..." | |
| try { | |
| $path = "HKLM:\SOFTWARE\Microsoft\Terminal Server Client" | |
| if (-not (Test-Path $path)) { New-Item -Path $path -Force | Out-Null } | |
| Set-ItemProperty -Path $path -Name "UseURCP" -Value 0 -Type DWord -Force | |
| Write-Output "URCP disable policy applied successfully." | |
| $Report.UrcpApplied = $true | |
| } | |
| catch { | |
| Write-Output "*** ERROR: Failed to apply URCP disable registry fix. ***" | |
| $Report.UrcpApplied = $false | |
| } | |
| } | |
| function Apply-AudioDisable { | |
| Write-Output "[7D] Applying audio redirection disable mitigation..." | |
| try { | |
| $path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" | |
| if (-not (Test-Path $path)) { New-Item -Path $path -Force | Out-Null } | |
| Set-ItemProperty -Path $path -Name "fDisableAudioRedirection" -Value 1 -Type DWord -Force | |
| Set-ItemProperty -Path $path -Name "fDisableAudioCapture" -Value 1 -Type DWord -Force | |
| Write-Output "Audio redirection disabled successfully." | |
| $Report.AudioDisableApplied = $true | |
| } | |
| catch { | |
| Write-Output "*** ERROR: Failed to disable audio redirection. ***" | |
| } | |
| } | |
| # ------------------------------------------------------------ | |
| # [8] Mitigation Decision Engine | |
| # ------------------------------------------------------------ | |
| Write-Output "" | |
| Write-Output "[8] Selecting mitigation strategy..." | |
| # OS Version Check | |
| $osKey = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" | |
| $CurrentBuild = (Get-ItemProperty -Path $osKey -Name CurrentBuild -ErrorAction SilentlyContinue).CurrentBuild | |
| $IsServer2025OrHigher = $false | |
| if ([int]$CurrentBuild -ge 26100) { | |
| $IsServer2025OrHigher = $true | |
| Write-Output "Detected Windows Server 2025 or higher - WDDM fallback will be skipped." | |
| } | |
| $runGpUpdate = $false | |
| if ($CheckOnly) { | |
| Write-Output "CheckOnly mode enabled - no mitigation will be applied." | |
| } | |
| else { | |
| # -------------------------------------------------------- | |
| # PIPELINE A: Transport Layer Mitigation (TCP-Only) | |
| # -------------------------------------------------------- | |
| $ShouldApplyTcp = $false | |
| if ($ForceTcpOnly) { | |
| Write-Output "-> ForceTcpOnly switch detected." | |
| $ShouldApplyTcp = $true | |
| } | |
| elseif ($Report.Udp4407) { | |
| Write-Output "-> UDP deadlock detected (Event 103 / Reason 4407)." | |
| $ShouldApplyTcp = $true | |
| } | |
| elseif ($Report.GraphicsDeadlock) { | |
| Write-Output "-> Graphics deadlock detected; flagging TCP-only transport to stabilize session pipeline." | |
| $ShouldApplyTcp = $true | |
| } | |
| if ($ShouldApplyTcp) { | |
| Apply-TcpOnly | |
| $Report.MitigationApplied = $true | |
| $runGpUpdate = $true | |
| } | |
| # -------------------------------------------------------- | |
| # PIPELINE B: Graphics & Rate Layer Mitigation (WDDM / URCP) | |
| # -------------------------------------------------------- | |
| # Explicit WDDM Manual Override | |
| if ($ForceWddmDisable) { | |
| if (-not $IsServer2025OrHigher) { | |
| Write-Output "-> ForceWddmDisable switch detected." | |
| Apply-WddmDisable | |
| $Report.MitigationApplied = $true | |
| $runGpUpdate = $true | |
| } else { | |
| Write-Output "-> ForceWddmDisable ignored - WDDM fallback is not supported on Server 2025+." | |
| } | |
| } | |
| # Automated Graphics Test Evaluations | |
| # Cinderella Match based on OS version | |
| elseif ($Report.GraphicsDeadlock) { | |
| # Server 2019 Optimization | |
| if ($CurrentBuild -eq 17763) { | |
| Write-Output "-> Applying native WDDM Disable fallback to legacy XDDM framework for Server 2019." | |
| Apply-WddmDisable | |
| $Report.MitigationApplied = $true | |
| $runGpUpdate = $true | |
| } | |
| # Server 2022 (and 2016) Optimization | |
| elseif (-not $IsServer2025OrHigher) { | |
| Write-Output "-> Applying modern URCP fix for Server 2022 to bypass software rasterization overhead." | |
| Apply-UrcpDisable | |
| $Report.MitigationApplied = $true | |
| # Note: gpupdate is skipped for URCP as it's a client key, but handled by transport if flipped | |
| } | |
| else { | |
| Write-Output "-> WDDM graphics fallback is blocked on Server 2025+. Managed purely via transport stabilization." | |
| } | |
| } | |
| # Implicitly link URCP optimization if running on Server 2022 when TCP is forced | |
| if ($ShouldApplyTcp -and $CurrentBuild -eq 20348 -and -not $Report.UrcpApplied) { | |
| Write-Output "-> Server 2022 detected with transport modifications active. Applying URCP safeguard proactively." | |
| Apply-UrcpDisable | |
| $Report.MitigationApplied = $true | |
| } | |
| # -------------------------------------------------------- | |
| # PIPELINE C: Audio Redirection Disable (rdpsnd mitigation) | |
| # -------------------------------------------------------- | |
| if (-not $CheckOnly) { | |
| $ShouldApplyAudio = $false | |
| if ($ForceAudioDisable) { | |
| Write-Output "-> ForceAudioDisable switch detected." | |
| $ShouldApplyAudio = $true | |
| } | |
| elseif ($Report.Severity -eq "CRITICAL") { | |
| Write-Output "-> Severity CRITICAL; applying audio redirection disable mitigation." | |
| $ShouldApplyAudio = $true | |
| } | |
| if ($ShouldApplyAudio) { | |
| Apply-AudioDisable | |
| $Report.AudioDisableApplied = $true | |
| $runGpUpdate = $true | |
| } | |
| } | |
| } | |
| # -------------------------------------------------------- | |
| # Group Policy Refresh | |
| # -------------------------------------------------------- | |
| if ($runGpUpdate) { | |
| Write-Output "" | |
| Write-Output "[9A] Refreshing Machine Group Policy Objects..." | |
| & "$env:SystemRoot\System32\gpupdate.exe" /Target:Computer /Force | |
| } else { | |
| Write-Output "No core Group Policy modifications required." | |
| } | |
| # ------------------------------------------------------------ | |
| # [9] TermService restart (only if mitigation applied) | |
| # ------------------------------------------------------------ | |
| if (-not $NoRestartRDS -and $Report.MitigationApplied -eq $true -and -not $CheckOnly) { | |
| Write-Output "" | |
| Write-Output "[9] Initiating State-Aware RDS Component Restart Pipeline..." | |
| $maxAttempts = 3 | |
| $attempt = 1 | |
| $stopped = $false | |
| # Core RDS pipeline dependencies | |
| $TargetServices = @("UmRdpService", "SessionEnv") | |
| # Track original states | |
| $ServiceStateTrack = @{} | |
| foreach ($svcName in $TargetServices) { | |
| $svcObj = Get-Service -Name $svcName -ErrorAction SilentlyContinue | |
| if ($svcObj) { | |
| $ServiceStateTrack[$svcName] = $svcObj.Status | |
| Write-Output "Initial baseline - ${svcName}: $($svcObj.Status)" | |
| } | |
| } | |
| # Shutdown Loop | |
| while ($attempt -le $maxAttempts -and -not $stopped) { | |
| Write-Output "Attempt ${attempt}: Shutting down dependent RDS services..." | |
| try { | |
| # Always attempt to stop dependencies (even if STOP_PENDING) | |
| foreach ($svcName in $TargetServices) { | |
| Write-Output "Stopping dependency: $svcName" | |
| Stop-Service -Name $svcName -Force -ErrorAction SilentlyContinue | |
| } | |
| Start-Sleep -Seconds 2 | |
| # Stop TermService | |
| Write-Output "Stopping Core TermService..." | |
| Stop-Service -Name TermService -Force -ErrorAction SilentlyContinue | |
| # === INTEGRATED: Dynamic 30-Second Wait Loop === | |
| $timeoutSeconds = 30 | |
| $elapsedSeconds = 0 | |
| $checkInterval = 2 | |
| Write-Output "Waiting up to $timeoutSeconds seconds for TermService to stop cleanly..." | |
| while ($elapsedSeconds -lt $timeoutSeconds) { | |
| $coreSvc = Get-Service -Name TermService -ErrorAction SilentlyContinue | |
| if ($coreSvc.Status -eq "Stopped") { | |
| Write-Output "Remote Desktop service engine stopped cleanly after $elapsedSeconds seconds." | |
| $stopped = $true | |
| break | |
| } | |
| if ($coreSvc.Status -eq "StopPending") { | |
| # Keep loop running, expected for a heavy session cleanup | |
| } else { | |
| Write-Output "TermService currently in transient/unexpected state: $($coreSvc.Status). Continuing to monitor..." | |
| } | |
| Start-Sleep -Seconds $checkInterval | |
| $elapsedSeconds += $checkInterval | |
| } | |
| # =============================================== | |
| # Break out of the primary attempt loop if the service stopped successfully | |
| if ($stopped) { break } | |
| Write-Output "TermService timed out or failed to stop during attempt ${attempt}." | |
| } | |
| catch { | |
| Write-Output "Stop attempt ${attempt} encountered a thread exception: $_" | |
| } | |
| $attempt++ | |
| } | |
| # Last resort: kill svchost container | |
| if (-not $stopped) { | |
| Write-Output "WARNING: Standard stop failed. Executing process-level termination..." | |
| try { | |
| # Modernized: Replaced legacy Get-WmiObject with Get-CimInstance | |
| $tsService = Get-CimInstance -ClassName Win32_Service -Filter "Name='TermService'" -ErrorAction SilentlyContinue | |
| $tsPid = $tsService.ProcessId | |
| if ($tsPid -and $tsPid -gt 0) { | |
| Write-Output "Killing TermService svchost container PID: $tsPid" | |
| Stop-Process -Id $tsPid -Force -ErrorAction SilentlyContinue | |
| Start-Sleep -Seconds 3 | |
| } | |
| $coreSvc = Get-Service -Name TermService -ErrorAction SilentlyContinue | |
| if ($coreSvc.Status -eq "Stopped") { | |
| Write-Output "TermService dropped successfully via process termination." | |
| $stopped = $true | |
| } | |
| } | |
| catch { | |
| Write-Output "*** CRITICAL ERROR: Process termination failed: $_ ***" | |
| } | |
| } | |
| # Restart pipeline | |
| if ($stopped) { | |
| Write-Output "Re-initializing Remote Desktop Services stack..." | |
| try { | |
| # Restore SessionEnv first if originally running | |
| if ($ServiceStateTrack["SessionEnv"] -eq "Running") { | |
| Write-Output "Restoring SessionEnv..." | |
| Start-Service -Name SessionEnv -ErrorAction SilentlyContinue | |
| Start-Sleep -Seconds 1 | |
| } | |
| # Start TermService | |
| Write-Output "Starting Core TermService..." | |
| Start-Service -Name TermService -ErrorAction Stop | |
| Start-Sleep -Seconds 2 | |
| # Restore UmRdpService if originally running | |
| if ($ServiceStateTrack["UmRdpService"] -eq "Running") { | |
| Write-Output "Restoring UmRdpService..." | |
| Start-Service -Name UmRdpService -ErrorAction SilentlyContinue | |
| } | |
| $finalCheck = Get-Service -Name TermService -ErrorAction SilentlyContinue | |
| Write-Output "Core RDS Pipeline Status: $($finalCheck.Status)" | |
| $Report.TermServiceRestarted = ($finalCheck.Status -eq "Running") | |
| } | |
| catch { | |
| Write-Output "*** ERROR: Failed to restore Remote Desktop service state: $_ ***" | |
| } | |
| } | |
| else { | |
| Write-Output "CRITICAL: TermService state is locked. A machine reboot is required." | |
| } | |
| } | |
| else { | |
| Write-Output "" | |
| Write-Output " TermService restart skipped (no mitigation applied or CheckOnly mode)." | |
| } | |
| Write-Output "" | |
| Write-Output "=== Unified RDP Regression Workflow For 2026-09 CU Completed ===" | |
| # ------------------------------------------------------------ | |
| # [10] Summary Report | |
| # ------------------------------------------------------------ | |
| # Write-Output "" | |
| # Write-Output "=== Summary Report ===" | |
| # $Report | |
| Write-Output "" | |
| Write-Output "===========================================================" | |
| Write-Output " RDP MITIGATION SUMMARY " | |
| Write-Output "===========================================================" | |
| Write-Output (" Event 20498 Detected : " + $Report.Event20498) | |
| Write-Output (" UDP Deadlock 4407 : " + $Report.Udp4407) | |
| Write-Output (" WDDM Graphics Deadlock : " + $Report.GraphicsDeadlock) | |
| Write-Output (" Severity : " + $Report.Severity) | |
| Write-Output (" TCP-Only Applied : " + $Report.TcpOnlyApplied) | |
| Write-Output (" WDDM Disable Applied : " + $Report.WddmApplied) | |
| Write-Output (" URCP Disable Applied : " + $Report.UrcpApplied) | |
| Write-Output (" Audio Disable Applied : " + $Report.AudioDisableApplied) | |
| Write-Output (" TermService Restarted : " + $Report.TermServiceRestarted) | |
| # Build command-line options summary | |
| $cmdOptions = "" | |
| if ($ForceTcpOnly) { $cmdOptions += " -ForceTcpOnly" } | |
| if ($ForceWddmDisable) { $cmdOptions += " -ForceWddmDisable" } | |
| if ($ForceAudioDisable) { $cmdOptions += " -ForceAudioDisable" } | |
| if ($NoRestartRDS) { $cmdOptions += " -NoRestartRDS" } | |
| if ($CheckOnly) { $cmdOptions += " -CheckOnly" } | |
| # Always show LogLookbackHours | |
| $cmdOptions += " -LogLookbackHours $LogLookbackHours" | |
| Write-Output (" CommandLine Options : " + $cmdOptions) | |
| Write-Output "===========================================================" | |
| Write-Output " Notes:" | |
| Write-Output " - TCP-only mitigation resolves UDP deadlocks (4407)." | |
| Write-Output " - WDDM disable resolves graphics pipeline deadlocks." | |
| Write-Output " - Use -ForceTcpOnly or -ForceWddmDisable to override." | |
| Write-Output " - Use -NoRestartRDS to skip TermService restart." | |
| Write-Output "===========================================================" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment