A common scenario for Windows XP was to make a master image on a system, sysprep it, create the image, and build on that master image for the next version of that image. Windows 7 made this difficult as you can only sysprep (better said, re-arm the license of) a system only 3 times.
Easiest way probably is to use a Virtual Machine and snapshot it right before sysprep. That way you can restore to right before the re-arm and build on that.
Alternatively, you can use sysprep referencing an unattend.xml file with an entry telling sysprep to skip the re-arm,
for example: sysprep.exe /oobe /generalize /unattend:"c:\unattend.xml" /quit
This unattend.xml file should contain at least the following:
<component name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Make sure to delete this xml before the unattended setup runs during deployment because it might interfere with the settings you inject during OSD.
Or, instead of using the XML, set the skip re-arm in the image with the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\SoftwareProtectionPlatform\SkipRearm. Note that the image does not retain this value, it gets reset after doing the sysprep.
Windows will skip the re-arm, but during the OSD process you can run the re-activation which will make the MAK or KMS key still unique to that device.
Oh no, I read this to late and already used my 3 times...
Don't worry, as mentioned bove, Windows 7 out-of-the-box can re-arm only 3 times, but if accidentally that happens to you, you can still recover the image and run the sysprep.
Running slmgr.vbs /dlv lets you check the re-arm counter. If it's 0 and you sysprep you will generally receive errors in the setupact.log and setuperr.log files like these:
Error [0x0f0073] SYSPRP RunExternalDlls:Not running DLLs; either the machine is in an invalid state or we couldn’t update the recorded state, dwRet = 31
Error [0x0f0082] SYSPRP LaunchDll: Failure occurred while executing 'C:\Windows\System32\slc.dll, SLReArmWindows', returned error code -1073425657
Error [0x0f0070] SYSPRP RunExternalDlls: An error occurred while running registry sysprep DLLs, halting sysprep execution. dwRet = -1073425657
Error [0x0f00a8] SYSPRP WinMain: Hit failure while processing sysprep generalize providers; hr = 0xc004d307
To remedy this, do the following
Open regedit and look for:
Set to value: 2
Set to value: 7
Than (this step isn't always necessary but it's better to include it anyway in your procedure):
msdtc -uninstall (wait a few seconds)
msdtc -install (wait a few seconds)
Reboot the system.
Now you can run sysprep again, but, don't forget to apply the things you learned in the first half of this document.