Windows 11 β Orphaned AppX registrations accumulating after user profile deletion and delaying Wi-Fi connectivity
I work in IT for a school district with a large number of shared Windows 11 laptops managed through Intune.
We've been experiencing an issue where some laptops take up to three minutes after being powered on before they even attempt to associate with our wireless networks.
After considerable investigation, we discovered that affected computers had accumulated thousands, and in some cases tens of thousands, of orphaned AppX registration records in the following database:
C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Machine.srd
We have a custom profile removal script deployed through Intune that removes student profiles after 31 days of inactivity while retaining staff profiles.
Through controlled testing, we confirmed that deleting Windows user profiles can leave behind associated AppX user and package registrations.
In an attempt to prevent these registrations from accumulating, we've tested several approaches:
- Profile deletion using WMI.
- The native Windows DeleteProfile API.
- Manual profile deletion through Windows System Properties.
- Windows Shared PC Account Manager.
- Removing AppX packages before and after profile deletion.
- Using the CleanupPackageForUserAsync API, including running it as SYSTEM at startup.
Unfortunately, none of these methods consistently removed all the associated AppX registrations.
We've developed a tool called WinState that boots into WinPE, backs up the StateRepository database, identifies orphaned users, removes their associated records and validates the database before putting it back in place.
Although directly modifying this database is not a Microsoft-supported procedure, our testing has been very promising, with significant improvements in wireless connectivity times following cleanup.
We've also developed a lightweight, read-only Intune detection script that uses the native Windows SQLite library to report total, current and orphaned StateRepository user counts across our fleet.
While we now have a way to identify and correct the problem, what we really want is a way to prevent it from happening in the first place.
Has anyone else encountered this issue? Has anyone found a reliable way to remove inactive Windows user profiles without leaving orphaned AppX registrations behind?
Ideally, we're looking for a Microsoft-supported method that can be automated through Intune without requiring the affected user to log in again.
Any suggestions or insight would be greatly appreciated.