SCCM TS Fails with error Unable to sysprep the machine 80040004

Prajwal Desai
Posted by Prajwal Desai

Working on troubleshooting SCCM issues is always interesting because every time you see an error, you learn more about it’s troubleshooting. As you know that unless we examine the log files, understanding the reason for error is difficult. One of the community forum user reported that SCCM task sequence was failing with error code 80004005. Now we know that it’s a common error and we see it most of the time when TS fails. The user was trying to capture reference operating system image task sequence. Basically he got stuck at error unable to sysprep the machine 80040004. Examining the smsts.log file contained the following code.

=======================[ OSDPrepareOS.exe ] =======================

Command line: "osdprepareos.exe" /activate:false /bmsd:false PrepareOS
Initialization successful PrepareOS
Local machine is not a domain controller. PrepareOS
System partition is NTFS PrepareOS
Verified deploy tools are present. PrepareOS
bufType != NetSetupDomainName, HRESULT=80040004 (..\deployutil.cpp,534) PrepareOS
Computer is part of domain 'Domain Name', disjoin and start image capture PrepareOS
VerifyNotDomainJoined( bDebugChecksOnly ), HRESULT=80040004 (..\deployutil.cpp,597) PrepareOS
DeployUtil::VerifyCaptureRequirements(m_bDebug), HRESULT=80040004 (prepareos.cpp,1258) PrepareOS
Machine does not meet OSD capture requirements. Capture can not continue. PrepareOS
Unable to sysprep the machine, hr=80040004 PrepareOS
Sysprep'ing the machine failed, hr=80040004 PrepareOS
Failed to run the action: Prepare OS.
The system cannot open the file. (Error: 00000004; Source: Windows)
Task sequence execution failed with error code 80004005

SCCM TS Fails with error Unable to sysprep the machine 80040004

If you have noticed the task sequence is failing at Prepare OS step. It checks if the machine is part of a domain and fails because the prerequisites are not met. The lines in log files are pretty much clear to understand why the TS is failing. It says computer is part of domain, disjoin and start the capture process. Capturing a machine using task sequence is not supported when the machine is joined to the domain. That’s the reason why the TS is failing. The machine must be in workgroup so that you can capture the installation image during the task sequence.

A trick used by admins – I have seen most of the admins joining computers to the domain, installing programs and selecting settings, and then sysprepping it. After a system restart the computer name is changed and rejoined it back to the domain.

What is Sysprep ? – Sysprep is the tool used to prepare a windows installation for image capture, or to prepare an installation to be shipped to an end user. There is a very good article on sysprep providers background and how they work. If you want to understand working of sysprep, go through that article. According to Microsoft sysprep removes the computer from the domain if it’s already added. Therefore I add the pc to domain, sysprep it which re-generated the SID, during sysprep I specifity to add it back to the domain.

So what are the workarounds ?.

  • In your apply network settings step, save the machine in workgroup.
  • You can always use the task sequence to build your master and capture manually using the capture media.
  • To capture an image from a reference computer manually, read this post.
Share This Article
Prajwal Desai
Posted by Prajwal Desai
Prajwal Desai is a Microsoft MVP in Intune and SCCM. He writes articles on SCCM, Intune, Windows 365, Windows Server, Windows 11, WordPress and other topics, with the goal of providing people with useful information.