Guest OS customization fails on Windows 11 VM
search cancel

Guest OS customization fails on Windows 11 VM

book

Article ID: 375270

calendar_today

Updated On:

Products

VMware vCenter Server 8.0 VMware vSphere ESXi 8.0

Issue/Introduction

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.

Environment

  • VMware vSphere ESXi 7.x
  • VMware vSphere ESXi 8.x

Cause

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.

  • Per-user package means that the Appx package is installed for a particular user account and is not available for other users of the computer.
  • All-user package means that the Appx has been provisioned into the image so that all users who use this image can access the app.
  • If an all-user package that's provisioned into the image was manually deprovisioned from the image but not removed for a particular user, the provider will encounter an error while cleaning out this package during sysprep. The provider will also fail if an all-user package that's provisioned into the image was updated by one of the users on this reference computer.

Resolution

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.

  • Run the following PowerShell cmdlets:
    • Import-Module Appx
    • Import-Module Dism
    • Get-AppxPackage -AllUsers | Where PublisherId -eq 8wekyb3d8bbwe | Format-List -Property PackageFullName,PackageUserInformation

  • Remove Appx package by running the following cmdlet:
    • Remove-AppxPackage -Package <packagefullname>

  • Remove the provisioning by running the following cmdlet:
    • 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.

Additional Information