When building a new Windows 11 VM using a VM template and script, the virtual machine guest OS customization specification is not running or completing as expected.
Sysprep has an additional provider that's added in Windows to clean Appx packages and to generalize the image. The provider works only if the Appx package is a per-user package or an all-user provisioned package.
To resolve this issue, remove the AppX package for the user who is running Sysprep, and also remove the provisioning of the package.
Before capturing the image in Audit Mode, either:
Disconnect from the Internet, or
Disable Automatic Updates
This prevents the Microsoft Store from updating apps.
Open PowerShell as Administrator.
Import necessary modules:
Identify installed AppX packages for all users (example for Microsoft default apps):
OR
List AppX packages for a specific user (excluding frameworks):
Remove the AppX package:
Remove the provisioning for all future users:
The issue does not occur when servicing an offline image. In that scenario, the provisioning is automatically cleared for all users. This includes the user who runs the command.