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 package for the user who's running sysprep, and also remove the provisioning. To do this, follow these steps:
Important :
To prevent Microsoft Store from updating apps, unplug the Internet connection or disable Automatic Updates in Audit mode before you create the image.
Import-Module Appx
Import-Module Dism
Get-AppxPackage -AllUsers | Where PublisherId -eq 8wekyb3d8bbwe | Format-List -Property PackageFullName,PackageUserInformation
Remove-AppxPackage -Package <packagefullname>
Remove-AppxProvisionedPackage -Online -PackageName <packagefullname>
If you try to recover from an update issue, you can reprovision the app after you follow these steps.
Note:
The issue does not occur if you are servicing an offline image. In that scenario, the provisioning is automatically cleared for all users. This includes the user who runs the command.