Server 2022 connection issues on upgrades

When upgrading my lab environment to 2308 I ran into a problem that has hit many users of 2022. Sometimes when you upgrade the VDA sessions will connect and immediately disconnect. RDP sessions are fine, and Console sessions work good. Looking in the event viewer will show messages like the following.

The Citrix Desktop Service detected that a user session has ended. Session 8d84b6d6-0597-4f49-b0ba-7aa6c272f590 for user 'administrator@lab.domain' has ended; reason code ConnectionFailure.

Uninstalling and reinstalling the VDA doesn’t fix it. Nor will rolling back to earlier VDAs. Instead the fix is a bit of PowerShell code you need to run after removing the VDA. Run this from an admin PowerShell window, then reinstall the latest VDA and you are back in business.

$iddHwId = "VEN_5853&DEV_1003"
$pnpDispDevPath = "HKLM:\SYSTEM\CurrentControlSet\Enum\SWD\RemoteDisplayEnum"
try
{
    $iddDevEntries = Get-ChildItem -Path $pnpDispDevPath -ErrorAction Stop| Where-Object Name -Match $iddHwId
}
catch
{
    Write-Output "Failed to query remote ID device entries"
    Write-Output $_
    return
}
if ($iddDevEntries.Count -eq 0)
{
     Write-Output "No remote ID device entries found."
     return
}
$iddDevEntries | ForEach-Object {
    
    $devName = ($_.Name -Split "\\")[-1]
    
    try
    {
        Remove-ItemProperty -Path $_.PsPath * -ErrorAction Stop
        Write-Output "Cleared values for $devName"
    }
    catch
    {
        Write-Output "Failed to clear values for $devName"
        Write-Output $_
    }
}

Leave a comment

Your email address will not be published. Required fields are marked *