Sysprep running under SYSTEM is hitting AppX/package validation issues on newer Windows Server 2025 builds. This matches known Sysprep/AppX failure patterns where provisioned or updated Microsoft Store apps are in an inconsistent state for the account that runs Sysprep.
Key points from the behavior described:
- Sysprep as an interactive user (via RDP) succeeds and the image boots with a working Explorer.
- Sysprep as SYSTEM (pipeline) completes, but the first logon hits a broken AppX state: Explorer crashes until all AppX packages are re-registered with the PowerShell loop.
- When trying to force Sysprep via
az vm run-commandas a user, the failing package varies (winget, Edge, WSL), which is typical of AppX provisioning inconsistencies.
On current Windows builds, Sysprep fails or leaves the image in a bad state if:
- A provisioned Store app (built into the image) has been updated or removed only for some users, or
- The account running Sysprep still has that app installed while provisioning metadata is inconsistent.
The supported remediation pattern is:
- For the account that runs Sysprep (in this case SYSTEM or the service context used by the pipeline), identify AppX packages that are installed for that account but not consistently provisioned.
- Remove those AppX packages for that account.
- Remove their provisioning from the image.
The documented steps are:
- Enumerate AppX packages and their user bindings
Import-Module Appx Import-Module Dism Get-AppxPackage -AllUsers | Where PublisherId -eq 8wekyb3d8bbwe | \ Format-List -Property PackageFullName,PackageUserInformation- This lists Microsoft-published packages and shows for which users they are installed.
- For non-Microsoft publishers, use:
Get-AppxPackage -AllUsers | \ Format-List -Property PackageFullName,PackageUserInformation
- For packages that show as Installed for the account that will run Sysprep (and that are causing issues), remove them for that account:
Remove-AppxPackage -Package <PackageFullName> - Remove provisioning for those packages from the image:
Remove-AppxProvisionedPackage -Online -PackageName <PackageFullName>
In an automated pipeline, this logic must run in the same security context that will later execute Sysprep (SYSTEM or the chosen service account) and before Sysprep is invoked. That ensures Sysprep does not encounter partially provisioned or user-updated AppX packages and avoids the broken Explorer state.
If the goal is to keep the image fully automated and avoid interactive RDP, incorporate the above AppX cleanup into the image build just before the Sysprep step, then run Sysprep with the recommended options for VM images:
C:\Windows\System32\Sysprep\sysprep.exe /generalize /oobe /mode:vm
(plus /shutdown or /quiet /quit depending on whether capture is manual or automated).
If Sysprep has already run and the image is corrupted (Explorer crashes at first logon), the official guidance is to re-create the image rather than trying to repair it post-Sysprep.
References: