Sysprep is widely used as Microsoft’s system preparation tool for Windows operating system deployment. It prepares Windows installation for duplication, auditing, and customer delivery. Sysprep is a command-line tool that can be run manually as well as through a script. This tool is extremely helpful for IT administrators who want to prepare the installation of Windows for duplication, auditing, and customer delivery.
Sysprep fails on removing or updating Provisioned Microsoft Store apps
As an IT professional or support agent, you may encounter Sysprep failure while you are creating a Windows reference PC/image or removing some of the side-loaded Appx packages from the existing Windows image.
The error occurs if you remove or update provisioned Windows Store apps that include built-in Windows images. Removing or updating these Apps will result in an error, and the tool Sysprep may fail to run.
If you receive A fatal error occurred while trying to Sysprep the machine error message, there could be three possible problem scenarios for it to happen.
A fatal error occurred while trying to Sysprep the machine
1] Trying to Remove some of the provisioned Microsoft Store apps
- In case, the user is creating a custom Windows 11 or Windows 10 reference computer which he/she wants to Sysprep and capture.
- The user wants to remove some built-in Windows Store apps (Appx packages) from this reference computer.
- The user runs
dism -online /Remove-ProvisionedAppxPackage /PackageName:<packagename>
to remove the Appx packages. - When the user tries to run the Sysprep operation in this scenario, he/she might get the above error, and the operation may fail.
Read: A fatal error occurred while trying to sysprep the machine
2] Remove a few side-loaded Appx packages from your image and customize it
If the user has an existing Windows image, many Microsoft Store apps are also side-loaded in the image.
The user wants to remove a few side-loaded Appx packages from the image and further customize it.
The user boots into the reference computer and further runs one of the following PowerShell commands in order to remove the built-ins of the Appx package:
Remove-AppxProvisionedPackage –PackageName <PackageName>
Remove-ProvisionedAppxPackage –PackageName <PackageName>
When the user tries to run Sysprep operation in such a scenario, the operation may fail with the abovementioned error.
Read: Sysprep was not able to validate your Windows installation.
3] Update the built-in Windows Store apps by using the Microsoft Store
- If the user is trying to create a Windows reference image
- The user connects to the Windows Store and tries to update the provisioned Windows Store apps from the Windows Store.
- When the user tries to run the Sysprep operation in this scenario, the operation fails with the same error as mentioned above.
An additional provider has been added to Windows 10 in Sysprep; this is to clean the Appx packages and generalize the image. The provider works only with the following packages:
- Per-user package: In this package, the Appx package is installed for a particular user account only and is not available for other users of the same PC.
- All-user package: In this package, the Appx package has been provisioned into the images, allowing all the users who use this image to access the app.
In the scenario where an all-user package that was provisioned into the image earlier and was manually de-provisioned from the image but was not removed for a particular user, the provider will get an error while cleaning out this package while running Sysprep.
The provider is also expected to fail if the users on the reference computer updated an all-user package that was provisioned into the image.
Removing the package for the user running Sysprep and also removing the provisioning can help resolve this issue. To prevent the Windows Store from automatically updating the apps, simply unplug the Internet connection or disable Automatic Updates in the Audit mode before creating the image.
KB2769827 lays down the following steps to fix this issue:
1] Run the following PowerShell cmdlet:
Import-Module Appx
2] Run this next:
Import-Module Dism
3] Finally Run this command:
Get-AppxPackage -AllUser | Where PublisherId -eq 8wekyb3d8bbwe | Format-List -Property PackageFullName,PackageUserInformation
Check the below:
In the output of this last cmdlet, check the users for whom the package is showing up as Installed. Delete these user accounts from the reference computer or log on to the computer by using these user accounts. Then, run the cmdlet in step 4 to remove the Appx package.
This command lists all packages published by Microsoft and installed by any user of that reference computer. Because the computer is to be sysprepped, we assume that these user profiles no longer require the package.
If you have manually provisioned the apps which belong to other publishers. List them with the command-
Get-AppxPackage -AllUser | Format-List –Property PackageFullName,PackageUserInformation
4] Run this:
Remove-AppxPackage -Package <packagefullname>
5] Remove the provisioning by running the following cmdlet:
Remove-AppxProvisionedPackage -Online -PackageName <packagefullname>
Kindly note that this issue does not occur if you are servicing an offline image. In such a scenario, the provisioning is cleared automatically for all the users and also includes the user who runs the command.
How do I fix Sysprep did not complete successfully?
If you receive Sysprep did not complete successfully error message, it could be because there is a pending Windows update, Microsoft Store app update, or due to a specific Service running in the background. To resolve the issue, check for Pending Updates and update or remove Microsoft Store Apps and see. You should also see the Sysprep logs located at C:\Windows\System32\Sysprep\Panther\setupact.log and setuperr.log for more specific details.