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 VMware vSphere ESXi

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.

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 AppX package for the user who is running Sysprep, and also remove the provisioning of the package.

Important:

  • Before capturing the image in Audit Mode, either:

    • Disconnect from the Internet, or

    • Disable Automatic Updates
      This prevents the Microsoft Store from updating apps.

Steps to Resolve:

  1. Open PowerShell as Administrator.

  2. Import necessary modules:

     
    Import-Module Appx
    Import-Module Dism
  3. Identify installed AppX packages for all users (example for Microsoft default apps):

     
    Get-AppxPackage -AllUsers | Where PublisherId -eq "8wekyb3d8bbwe" | Format-List PackageFullName, PackageUserInformation

    OR

    List AppX packages for a specific user (excluding frameworks):

     
    Get-AppxPackage -User <username> | Where-Object {$_.IsFramework -eq $false}
  4. Remove the AppX package:

     
    Remove-AppxPackage -Package <PackageFullName>
  5. Remove the provisioning for all future users:

     
    Remove-AppxProvisionedPackage -Online -PackageName <PackageFullName>

Note:

  • 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.

Additional Information