Sysprep is widely used as Microsoft’s system preparation tool for Windows operating system deployment. It prepares an installation of Windows 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 Windows 10
As an IT professional or support agent, you may encounter Sysprep failure while you are creating a Windows 10 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 the Windows Store Apps which also include built-in Windows images will result in an error where 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
Scenario 1: Trying to Remove some of the provisioned Windows Store apps
- In case, the user is creating a custom Windows 10 or Windows 8 reference computer which he/she wants to Sysprep and capture.
- The user wants to remove some of the 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.
- Post when the user tries to run the Sysprep operation in this scenario, he/she might get the above error and the operation may fail.
Scenario 2: Remove a few side-loaded Appx packages from your image and customize it
In case, the user has an existing Windows image, also many Windows Store apps side-loaded in the image.
The user wants to remove a few of the 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 same error mentioned above.
Scenario 3: Update the built-in Windows Store apps by using the Windows 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 tried to run Sysprep operation in this scenario, the will lead to the operation getting failed with the same error as mentioned above.
An additional provider has been added in Windows 10 in Sysprep, this is to clean the Appx packages and also to 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 this allows all the users who use this image to access the app.
In the scenario where an all-user package which 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 case an all-user package that was provisioned into the image was updated by the users on the reference computer.
Removing the package for the user running Sysprep, and also remove the provisioning can help in resolving this issue. In order 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:
2] Run this next:
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 that were 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 in case 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 actually runs the command.