Autopilot Profile causes Device Rename after ConfigMgr OSD Task Sequence and Breaks AD Domain Trust

We got some new hardware models in this week and added drivers to our ConfigMgr OSD Task Sequence (with Windows 10 1909 serviced with November 2020 updates) to test. One of the devices kept ending up with a broken domain trust relationship when you attempt to log in immediately following build completion.

The security database on the server does not have a computer account for this workstation trust relationship
The security database on the server does not have a computer account for this workstation trust relationship

One clue that we had was that something was renaming the device. We have a very basic naming convention SITE-SERIAL where SITE is 2-5 character code for the AD site/OU a device will be assigned to. The device was be in Active Directory in the right OU and properly domain joined, but at the logon screen in the username field if we typed .\ to show the device name instead of the domain name, the device name was only the SERIAL, no SITE- prefix. The smsts.log, setupact.log, unattend.xml all showed the correct device name through the entire process. Here’s the rest of the story…

Note - the serial in the screenshots doesn’t match the logs due to obfuscation of prod data
Note - the serial in the screenshots doesn't match the logs due to obfuscation of prod data

Trudging Through Logs

Like most people, I love (or is is loathe) digging through logs looking for a needle in a haystack. In this case, I needed to find evidence that showed that the device was properly named, but then was changed sometime later. I knew that it was named correctly at least until the domain join step and after digging through smsts.log, it was clear that it wasn’t being changed during or by the Task Sequence at all. It was coming afterwards. I moved to the Event Viewer and started looking for Event ID 6011 which would show that the device name had been changed and the device had been rebooted.

 1Information	12/1/2020 2:22:35 PM	EventLog	6011	None
 2Log Name:      System
 3Source:        EventLog
 4Date:          12/1/2020 2:22:35 PM
 5Event ID:      6011
 6Task Category: None
 7Level:         Information
 8Keywords:      Classic
 9User:          N/A
10Computer:      12345678.asd.net
11Description:
12The NetBIOS name and DNS host name of this machine have been changed from ASD-12345678 to 12345678.
13Event Xml:
14<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
15  <System>
16    <Provider Name="EventLog" />
17    <EventID Qualifiers="32768">6011</EventID>
18    <Level>4</Level>
19    <Task>0</Task>
20    <Keywords>0x80000000000000</Keywords>
21    <TimeCreated SystemTime="2020-12-01T20:22:35.941883400Z" />
22    <EventRecordID>927</EventRecordID>
23    <Channel>System</Channel>
24    <Computer>12345678.asd.net</Computer>
25    <Security />
26  </System>
27  <EventData>
28    <Data>ASD-12345678</Data>
29    <Data>12345678</Data>
30  </EventData>
31</Event>

Once I had the base timestamp to work from, I was able to narrow my search to a specific time that this could have happened. I scrolled back in time and and found Event ID 1074 which showed that the reboot was triggered by CloudExperienceHost.

 1Information	12/1/2020 2:22:04 PM	User32	1074	None
 2Log Name:      System
 3Source:        User32
 4Date:          12/1/2020 2:22:04 PM
 5Event ID:      1074
 6Task Category: None
 7Level:         Information
 8Keywords:      Classic
 9User:          SYSTEM
10Computer:      ASD-12345678.asd.net
11Description:
12The process C:\Windows\System32\CloudExperienceHostBroker.exe (ASD-12345678) has initiated the restart of computer ASD-12345678 on behalf of user NT AUTHORITY\SYSTEM for the following reason: Operating System: Reconfiguration (Unplanned)
13 Reason Code: 0x20004
14 Shutdown Type: restart
15 Comment: 
16Event Xml:
17<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
18  <System>
19    <Provider Name="User32" Guid="{b0aa8734-56f7-41cc-b2f4-de228e98b946}" EventSourceName="User32" />
20    <EventID Qualifiers="32768">1074</EventID>
21    <Version>0</Version>
22    <Level>4</Level>
23    <Task>0</Task>
24    <Opcode>0</Opcode>
25    <Keywords>0x8080000000000000</Keywords>
26    <TimeCreated SystemTime="2020-12-01T20:22:04.988802400Z" />
27    <EventRecordID>918</EventRecordID>
28    <Correlation />
29    <Execution ProcessID="836" ThreadID="3048" />
30    <Channel>System</Channel>
31    <Computer>ASD-12345678.asd.net</Computer>
32    <Security UserID="S-1-5-18" />
33  </System>
34  <EventData>
35    <Data Name="param1">C:\Windows\System32\CloudExperienceHostBroker.exe (ASD-12345678)</Data>
36    <Data Name="param2">ASD-12345678</Data>
37    <Data Name="param3">Operating System: Reconfiguration (Unplanned)</Data>
38    <Data Name="param4">0x20004</Data>
39    <Data Name="param5">restart</Data>
40    <Data Name="param6">
41    </Data>
42    <Data Name="param7">NT AUTHORITY\SYSTEM</Data>
43  </EventData>
44</Event>

When I looked at C:\Windows\Panther\UnattendGC\setupact.log I noticed that CloudExperienceHost had failed and created a memory dump around the same time the device rename and matched up with the timestamp on the restart event.

 12020-12-01 14:21:45, Info                         [taskhostw.exe] OOBE Monitor event received: 103
 22020-12-01 14:21:50, Info                         [CloudExperienceHostBroker.exe] Failed to load oobe.xml file at C:\WINDOWS\system32\oobe\info\oobe.xml with hr=0x80070003
 32020-12-01 14:21:50, Info                         [CloudExperienceHostBroker.exe] Failed to load oobe.xml file at C:\WINDOWS\system32\oobe\info\default\oobe.xml with hr=0x80070003
 42020-12-01 14:21:50, Info                         [CloudExperienceHostBroker.exe] Failed to load oobe.xml file at C:\WINDOWS\system32\oobe\info\244\oobe.xml with hr=0x80070003
 52020-12-01 14:21:50, Info                         [CloudExperienceHostBroker.exe] Failed to load oobe.xml file at C:\WINDOWS\system32\oobe\info\default\1033\oobe.xml with hr=0x80070003
 62020-12-01 14:21:50, Info                         [CloudExperienceHostBroker.exe] Failed to load oobe.xml file at C:\WINDOWS\system32\oobe\info\244\1033\oobe.xml with hr=0x80070003
 72020-12-01 14:21:50, Info                         [CloudExperienceHostBroker.exe] Opting in to IncludeDriverSets
 82020-12-01 14:21:50, Info                         [CloudExperienceHostBroker.exe] CZDPTask setting OOBE_GLOBAL_SETTING_ZDPSTATUS ZDP_Scanning.
 92020-12-01 14:21:51, Info                         [taskhostw.exe] OOBE Monitor event received: 104
102020-12-01 14:21:56, Info                         [CloudExperienceHostBroker.exe] ISearchCompletedCallback::Invoke called
112020-12-01 14:21:56, Info                         [CloudExperienceHostBroker.exe] Wait result from WU ZDP Search: 0X1
122020-12-01 14:21:56, Info                         [CloudExperienceHostBroker.exe] Found 0 updates in collection.
132020-12-01 14:21:56, Info                         [CloudExperienceHostBroker.exe] CZDPTask::CancelTask() Invoked.
142020-12-01 14:21:56, Info                         [CloudExperienceHostBroker.exe] CZDPTask setting OOBE_GLOBAL_SETTING_ZDPSTATUS ZDP_Finished.
152020-12-01 14:22:09, Info                         [taskhostw.exe] OOBE Monitor task stopped
162020-12-01 14:22:36, Info                         [svchost.exe] Enter WinReIsWimBootEnabled
172020-12-01 14:22:36, Info                         [svchost.exe] Parameters: pszWinDir: NULL
182020-12-01 14:22:36, Info                         [svchost.exe] Exit WinReIsWimBootEnabled returns 0 with last error: 0x0
192020-12-01 14:22:38, Info                         [taskhostw.exe] OOBE Monitor task background thread started
202020-12-01 14:22:39, Info                         [taskhostw.exe] OOBE Monitor event received: 101
212020-12-01 14:22:39, Info                         [taskhostw.exe] OOBE Monitor event received: 102
222020-12-01 14:22:40, Info                         [taskhostw.exe] OOBE Monitor event received: 103
232020-12-01 14:22:42, Info                         [CloudExperienceHostBroker.exe] UserOOBEController::Exit() started [1]
242020-12-01 14:22:42, Info                         [taskhostw.exe] OOBE Monitor event received: 999
252020-12-01 14:22:42, Info                         [CloudExperienceHostBroker.exe] Clearing Auto-logon values per request
262020-12-01 14:22:42, Error                        [CloudExperienceHostBroker.exe] Disabling default account failed [hr=0xD00000E5]
272020-12-01 14:25:40, FatalError [0x090001] PANTHR Exception (code 0xC0000005: ACCESS_VIOLATION) occurred at 0x00007FFDDADD2236 in C:\Windows\System32\oobe\UserOOBE.dll (+0000000000022236).  Minidump attached (47855 bytes) to diagerr.xml and C:\WINDOWS\Panther\UnattendGC\mndF37E.diagerr.mdmp.

For no real reason, I decided to check if the machine was getting an Autopilot profile. The Event Viewer showed that the device had gotten an Autopilot json file, which seemed odd since this device shouldn’t have had a profile assigned yet. I opened C:\Windows\ServiceState\Autopilot and found AutopilotDDSZTDFile.json. In here, I found the smoking gun!

 1{
 2    "AutopilotServiceCorrelationId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
 3    "ZtdRegistrationId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
 4    "AadDeviceId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
 5    "CloudAssignedOobeConfig": 284,
 6    "CloudAssignedDomainJoinMethod": 0,
 7    "CloudAssignedForcedEnrollment": 1,
 8    "CloudAssignedTenantDomain": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
 9    "CloudAssignedTenantId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
10    "CloudAssignedMdmId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
11    "CloudAssignedRegion": "os-default",
12    "CloudAssignedLanguage": "os-default",
13    "CloudAssignedDeviceName": "%SERIAL%",
14    "DeploymentProfileName": "Autopilot",
15    "IsExplicitProfileAssignment": true,
16    "CloudAssignedAutopilotUpdateDisabled": 1,
17    "CloudAssignedPrivacyDiagnostics": 0,
18    "HybridJoinSkipDCConnectivityCheck": 0,
19    "CloudAssignedAutopilotUpdateTimeout": 1800000,
20    "PolicyDownloadDate": "2020-12-01T20:21:49Z"
21}

Making Sense of Things

As you may know, you can only assign custom naming to Azure AD Joined devices, not Hybrid, during Autopilot. How could this be happening during OSD?

During OSD, the device is installing Windows then apps and settings and is locked out until it’s done. Once it is finished, it will reboot and is supposed to skip OOBE and go to the logon screen. We recently removed our custom Unattend.XML file from our TS since we were specifically using it to suppress OOBE post OSD using some now deprecated settings (SkipUserOOBE & SkipMachineOOBE) that still work.

A Square Dozen Image
https://docs.microsoft.com/windows/deployment/deploy-windows-mdt/create-a-windows-10-reference-image#edit-the-unattendxml-file-for-windows10-enterprise

A Square Dozen Image
Network OOBE Screen

So it appears in the brief moment where OOBE is being shown, the device is contacting the Autopilot service and pulling down an assigned Autopilot profile.

Finding a Workaround

This next section describes the troubleshooting process that I used to validate the source of the issue.

Option 1 (supported)

The ‘supported’ solution to this problem would be to NOT assign Autopilot profiles (specifically ones with naming templates configured) to devices that you are NOT Autopiloting. This is the cleanest option and doesn’t require adding in deprecated configurations to your unattend.xml. This SHOULDN’T be happening, but as Michael Niehaus pointed out to me after reading this post, he tried for 2 years to get this fixed and ultimately, just don’t do it (assign an Autopilot profile to a non-Autopilot device) that way.

Option 2 (unsupported)

To test my theory about OOBE, I added unattend.XML back to the Task Sequence and built the machine. The device didn’t pull down the Autopilot profile and didn’t get renamed. I then removed the deprecated lines from the unattend.xml file and built the machine again. This time it failed the same as before, confirming my suspicion.

This is my default unattend.xml.

 1<?xml version="1.0"?>
 2<unattend xmlns="urn:schemas-microsoft-com:unattend">
 3    <settings pass="oobeSystem">
 4        <component name="Microsoft-Windows-Shell-Setup" 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">
 5            <OOBE>
 6                <SkipUserOOBE>true</SkipUserOOBE>
 7                <SkipMachineOOBE>true</SkipMachineOOBE>
 8                <NetworkLocation>Work</NetworkLocation>
 9                <ProtectYourPC>3</ProtectYourPC>
10            </OOBE>
11            <TimeZone>Central Standard Time</TimeZone>
12        </component>
13        <component name="Microsoft-Windows-International-Core" 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">
14            <InputLocale>0409:00000409</InputLocale>
15            <SystemLocale>en-US</SystemLocale>
16            <UILanguage>en-US</UILanguage>
17            <UILanguageFallback>en-US</UILanguageFallback>
18            <UserLocale>en-US</UserLocale>
19        </component>
20    </settings>
21    <settings pass="specialize">
22        <component name="Microsoft-Windows-Shell-Setup" 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">
23            <ComputerName>ComputerName</ComputerName>
24        </component>
25    </settings>
26    <cpi:offlineImage cpi:source="wim:c:/temp/install.wim#Windows 10 Enterprise" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
27</unattend>

Apply Operating System with unattend.xml
Apply Operating System with unattend.xml

Here’s the unattend.xml after the Task Sequence Apply steps have completed just before the Setup Windows and ConfigMgr step.

 1<?xml version="1.0"?>
 2<unattend xmlns="urn:schemas-microsoft-com:unattend">
 3	<cpi:offlineImage cpi:source="wim:c:/temp/install.wim#Windows 10 Enterprise" xmlns:cpi="urn:schemas-microsoft-com:cpi"/>
 4	<settings xmlns="urn:schemas-microsoft-com:unattend" pass="oobeSystem"><component name="Microsoft-Windows-Shell-Setup" language="neutral" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 5			<OOBE>
 6			    <SkipUserOOBE>true</SkipUserOOBE>
 7                <SkipMachineOOBE>true</SkipMachineOOBE>
 8				<ProtectYourPC>3</ProtectYourPC>
 9				<NetworkLocation>Work</NetworkLocation>
10				<HideEULAPage>true</HideEULAPage>
11			</OOBE>
12			<TimeZone>Central Standard Time</TimeZone>
13			<RegisteredOrganization>A Square Dozen Lab</RegisteredOrganization>
14			<UserAccounts>
15				<AdministratorPassword>
16					<Value>XXXXXXXXXXXXXXXXX</Value>
17					<PlainText>false</PlainText>
18				</AdministratorPassword>
19			</UserAccounts>
20			<RegisteredOwner>A Square Dozen Lab</RegisteredOwner>
21		</component>
22		<component name="Microsoft-Windows-International-Core" language="neutral" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
23			<SystemLocale>en-US</SystemLocale>
24			<UserLocale>en-US</UserLocale>
25			<UILanguage>en-US</UILanguage>
26			<InputLocale>0409:00000409</InputLocale>
27			<UILanguageFallback>en-US</UILanguageFallback>
28		</component>
29	</settings><settings xmlns="urn:schemas-microsoft-com:unattend" pass="specialize"><component name="Microsoft-Windows-Shell-Setup" language="neutral" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
30			<ComputerName>ASD-123245678</ComputerName>
31		</component>
32		<component name="Microsoft-Windows-UnattendedJoin" language="neutral" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
33			<Identification>
34				<Credentials>
35					<Username>ASDAdmin</Username>
36					<Domain>ASD</Domain>
37					<Password>XXXXXXXXXX</Password>
38				</Credentials>
39				<MachineObjectOU>OU=Workstations,OU=Lab,DC=asd,DC=net</MachineObjectOU>
40				<JoinDomain>ASD.NET</JoinDomain>
41			</Identification>
42		</component>
43		<component name="Microsoft-Windows-Deployment" language="neutral" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
44			<RunSynchronous>
45				<RunSynchronousCommand><Order>1</Order>
46					<Description>disable user account page</Description>
47					<Path>reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Setup\OOBE /v UnattendCreatedUser /t REG_DWORD /d 1 /f</Path>
48				</RunSynchronousCommand>
49			</RunSynchronous>
50		</component>
51	</settings></unattend>

As you can see on lines 6 & 7 above SkipUserOOBE and SkipMachineOOBE are included in the XML and make the issue go away.

Wrapping it all up

This was a weird one for sure and this feels like a bug. The workarounds are simple enough that this isn’t a show stopped, but trying to find the source of the bug was definitely a head scratcher. I haven’t had time to test with any other OS versions or even non-serviced versions yet but would be interested to see if they suffer the same issues. I seem to recall that the OOBE issues that required the custom unattend.xml only showed up on offline serviced or captured images, but not on OEM media.

P.S.

You may be asking yourself why I was doing OSD when I had AutoPilot assigned for AAD Join. Well, the device we were testing was a demo unit that had been registered to another company’s tenant and had THEIR Autopilot profile assigned. I had no way of deleting the device or unassigning the profile. The vendor has since resolved the issue, but it helped highlight a deficiency in their process as well, so win-win I guess.

Also, I was unable to find any Autopilot logs that actually show the device rename being triggered which also bugs me…