You may run in a situation, when LoadState captures the same profile two or more times. This happens if there are two or more SIDs under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList have a value for ProfileImagePath pointing to the same folder.
Excluding the old domain with /ue:OLDDOMAIN\* does not help if offline scenario. So the only way to fix it would be deleting old orphan entries from registry. Attached script does exactly that.
It takes two parameters:
OldDomainSID and NewDomainSID.
It enumerates profiles from
If it finds a profile from new
domain, it looks for the profile pointing to the same folder in old domain then
deletes that profile record in registry.
Put this script under “Scripts\Custom” folder in your MDT package, run it before User State Capture step for UDI or ZTI/LTI like this:
cscript.exe “%DeployRoot%\Scripts\Custom\FixProfilesBeforeUSMT.wsf” /OldDomainSID:S-1-5-21-1111111111-776500477-1237804090 /NewDomainSID:S-1-5-21-2222222222-3324038498-27948981
You can grab old domain and new domain SIDs from the same registry key of affected computer: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList , just take out the part after last dash.