If you need to run sysprep then you may run into a couple of problems when you try to run sysprep on an upgraded servers, mainly this error a below:
How did I know it was an upgrade that broke it?
Well, if you look at the log files the error references then you will notice it will look something like this:
2024-09-10 16:28:20, Warning SYSPRP ActionPlatform::GetValue: Error from RegQueryValueEx on value SysprepMode under key HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup\Sysprep; dwRet = 0x2
2024-09-10 16:28:20, Error [0x0f0036] SYSPRP spopk.dll:: Sysprep will not run on an upgraded OS. You can only run Sysprep on a custom (clean) install version of Windows.
2024-09-10 16:28:20, Error [0x0f0082] SYSPRP ActionPlatform::LaunchModule: Failure occurred while executing 'Sysprep_Clean_Validate_Opk' from C:\Windows\System32\spopk.dll; dwRet = 0x139f2024-09-10 16:28:20, Error SYSPRP SysprepSession::Validate: Error in validating actions from C:\Windows\System32\Sysprep\ActionFiles\Cleanup.xml; dwRet = 0x139f
2024-09-10 16:28:20, Error SYSPRP RunPlatformActions:Failed while validating SysprepSession actions; dwRet = 0x139f
2024-09-10 16:28:20, Error [0x0f0070] SYSPRP RunExternalDlls:An error occurred while running registry sysprep DLLs, halting sysprep execution. dwRet = 0x139f
2024-09-10 16:28:20, Error [0x0f00d8] SYSPRP WinMain:Hit failure while pre-validate sysprep cleanup internal providers; hr = 0x8007139f
Why does this happen?
Well, since Server 2012 R2 The advice is Jones to do a fresh install also known as a clean installed any of your existing data.
If you wish to keep your existing data, the other option is an upgrade on contrast, this works very differently to a clean install.
The upgrade mode will take all your settings, application data and move that data to the version of Windows you’re upgrading to, which means if you have any corrupt files or inconsistent files these also get copied over with the upgrade, which then by definition, can cause system instabilities and application errors - it is now recommended you do a fresh install and reinstalled all your applications.
Upgrade flags have been detected from the Registry
If however, you still need to run sysprep We need to do some Registry housekeeping in order to run this utility successfully on an upgraded copy of Windows.
We need to delete a certain folder from the Registry and then change 2x individual keys, which includes a delete operation and an update operation.
Important : These actions will change the Registry. please ensure you have a backup of these settings before you delete/update them
Remove this folder from the Registry:
Computer\HKEY_LOCAL_MACHINE\SYSTEM\Setup\Upgrade
Remove this individual key from the Registry:
Computer\HKEY_LOCAL_MACHINE\SYSTEM\Setup\Upgrade
Set this REG_DWORD to Hexadecimal "7" for this Registry key:
Computer\HKEY_LOCAL_MACHINE\SYSTEM\Setup\Status\SysprepStatus\CleanupState
Sysprep will now work, no reboot required.