AVD issue: SessionHost unhealthy SxsStack listener is not ready - Code -2147467259

A few days ago, I got an email from a customer concerning that a lot of Azure Virtual Desktop (AVD) session hosts showing an error message from the internal health check:

SessionHost unhealthy SxSStack listener is not ready - Code -2147467259

Unfortunately, there was no failed event log from the WVDAgent in the application log. But the RemoteDesktopServices log shows some issues with the SxSStack as expected. Reinstalling the AVD agents doesn't resolve the issue. But we found an easier way to bring the hosts back to life: Uninstalling the SxS Stack package and rebooting the host.

We used PowerShell to create a single-line script and Hydra to execute it on all affected session host:

Uninstall-Package -Name "Remote Desktop Services SxS Network Stack" -AllVersions -Force

The short script can be deployed with #WVDAdmin, #Hydra, or any other solution having access to the hosts.