Ground Truth field notes · defensive security

Home›Endpoint Security›Hardening & compliance

Deep dive + field case · device identity

"Device authentication failed": hybrid join, the PRT and Intune, end to end

A user can't sign in to anything. Windows says the device couldn't authenticate and offers to register it, then the registration fails. The tempting fix is to wipe or retire the laptop. The right fix takes twenty minutes and touches no user data, but only once you understand how the laptop's identity is actually built.

This post has two halves. The first half is the machinery: how a domain-joined Windows PC becomes a device Entra trusts, how that trust turns into the user's Primary Refresh Token (PRT), and how the PRT is what gets the device into Intune. The second half is a real ticket where that chain broke, walked through the way it was actually worked: the evidence, what each clue meant, the fix, and how we proved it was fixed.

If you only remember one idea, make it this one: device identity, user token and device management are a chain, not three separate features. Break the first link and everything after it fails too, with error messages that point at the wrong place.

THE DEPENDENCY CHAIN · EACH LINK NEEDS THE ONE BEFORE IT 1 Join hybrid join, device identity AzureAdJoined 2 PRT user's token, device-bound AzureAdPrt 3 Intune enrolled, with a device record MdmUrl 4 Comply state written back to Entra isCompliant 5 Sign-in CA evaluates, SSO to apps Outlook, Teams broke here Entra stopped recognising the device …so every link after it failed too, and the user only saw the last one
The whole post in one picture. The user reported link 5: "I can't sign in to Outlook." The cause was link 1. Fixing anything in between (resetting her password, re-licensing, wiping the laptop) would not have helped.

01One laptop, four records

Before the mechanism, the cast. Most confusion comes from not knowing which object is which.

A hybrid-joined, Intune-managed, Autopilot-registered laptop is represented in four different places. They share a name or a serial number, which makes them look like duplicates, but each one does a different job and they are linked in a specific order.

ONE PHYSICAL DEVICE · FOUR RECORDS The laptop WINDOWS + TPM device key private half, sealed in the TPM device cert subject CN = the device ID The source of truth. Every other record is only valid while it matches what's in here. AD computer object userCertificate = public cert Entra device object device ID · public key · join type Intune device record points at an Entra device ID Autopilot placeholder named after the serial number writes cert registers key MDM check-ins hardware hash, once Entra Connect sync linked by device ID
Read it top to bottom. The laptop writes its public cert to AD, Entra Connect carries it into Entra, and Intune hangs off the Entra device ID. The Autopilot placeholder sits off to the side. It was created from an uploaded hardware hash and never signs in.
RecordWhat it is forIf you delete it
AD computer objectDomain membership, GPOs, and the carrier for userCertificateThe device falls off the domain. Don't.
Entra device objectWhat Entra checks when the device signs a request. Holds the public key, join type and compliance flagDevice authentication fails immediately (the subject of this post)
Intune recordPolicies, apps, compliance, BitLocker/LAPS settingsThe device unenrolls at next check-in. User data is untouched
Autopilot placeholderRemembers "this hardware belongs to us" for future resetsAutopilot no longer recognises the hardware at the next reimage

02How hybrid join actually works

The device gets its identity from a key it generates itself, carried to Entra by a cert in AD.

"Hybrid joined" means the PC is joined to on-prem AD and registered in Entra as the same machine. In a managed (non-federated) tenant, the registration leg is an elegant bit of engineering: the device never sends a password anywhere. It proves who it is with a key only it holds, and it uses AD plus Entra Connect as the trusted courier that introduces that key to Entra.

Device (TPM) Domain ctrl Entra Connect Entra (DRS) PASS 1 · DEVICE INTRODUCES ITSELF VIA AD ① read SCP: which tenant? ② new key pair in the TPM + self-signed cert, CN = device ID ③ write userCertificate ④ next sync cycle sees the cert ⑤ create device object Registered: Pending PASS 2 · DEVICE'S NEXT JOIN-TASK RUN (SIGN-IN OR SCHEDULE) ⑥ prove I hold the private key · register device + transport keys ⑦ registered · dsregcmd: AzureAdJoined : YES Only after ⑦ can a user on this device be issued a PRT.
Two passes, not one. The first run of the join task only gets the cert into AD. Entra doesn't know the device until Entra Connect syncs it, so AzureAdJoined stays NO in between. That gap looks like failure and isn't.

The pieces, in plain terms:

This also explains the prerequisites people hit in the field. The computer's OU has to be in Entra Connect sync scope, or step ④ never happens. The device needs line of sight to a DC for steps ① and ③, which is why office network or VPN matters.

03The PRT: where the device and the user meet

The user's single sign-on token is only issued to a device Entra recognises.

When a user signs in to Windows, the Entra plugin in the Windows sign-in stack sends her credentials to Entra in a request signed with the device key. Entra looks up the device object, checks that it exists, is enabled and has a public key matching that signature, and only then issues a Primary Refresh Token. The PRT is valid for 14 days, is renewed silently while the device is in use, and is bound to a session key kept in the TPM.

Every M365 app on the machine (Outlook, Teams, Edge, OneDrive) quietly trades the PRT for its own access token. That is what SSO on Windows is. It's also why a broken device identity shows up as "every app is broken at once."

AT EVERY WINDOWS SIGN-IN User signs in password or Windows Hello Windows signs the token request with the TPM device key Entra: is the device known and does the key match? yes PRT issued 14 days, bound to the TPM SSO works Outlook, Teams, Edge, OneDrive no AADSTS50155 device authentication failed AzureAdPrt : NO Every app fails "register this device" prompt that then errors out The user's password can be perfect. Without a device Entra recognises, there is no PRT.
Why the user's symptom was misleading. The prompt to "register the device" is Windows trying to recover from the red branch. It fails for the same reason the sign-in did: the device can't prove an identity Entra knows about.

04How the device lands in Intune

Auto-enrollment is triggered by a GPO but performed with the user's token.

For hybrid devices, enrollment is the third link and it depends on the first two:

  1. A GPO linked to the computers' OU turns on Enable automatic MDM enrollment using default Azure AD credentials (set to User Credential). Some environments also scope it with a security group. All the GPO does is create a scheduled task under \Microsoft\Windows\EnterpriseMgmt.
  2. When the user signs in and holds a PRT, that task uses her token to enroll the device. It only works if she's inside the MDM user scope on the Microsoft Intune app under Entra → Mobility (MDM and WIP).
  3. Intune creates the device record, links it to the Entra device ID and sets her as primary user.
  4. Intune writes back to the Entra device object: MDM: Microsoft Intune and, once evaluated, the compliance flag. Conditional Access reads that flag.

Mental model

Hybrid join gives the laptop a passport. The PRT is the user's boarding pass, and it's only printed for someone travelling with a valid passport. Intune enrollment is checking in at the gate with that boarding pass. Cancel the passport and nothing after it works, however valid the user's own ID is.

05The field case: what we saw

A user's laptop, every app failing, and one very informative command.

The ticket was simple: a user couldn't sign in to any M365 app. Windows reported that device authentication had failed and offered to register the device; the registration errored out. Before escalating, someone had already looked in Entra, found the laptop's device object with a blank join type, and deleted it as a bad object. The laptop was still listed in Intune, and the open question was whether to Retire, Wipe or Fresh Start it.

The first thing to run on any device-auth problem is dsregcmd /status. Trimmed and anonymised, it said:

# Device State
             AzureAdJoined : YES
              DomainJoined : YES
# Device Details
                  DeviceId : 1a2b3c4d-0000-4000-8000-00000000c0de
 DeviceCertificateValidity : [ 2019-03-14 -- 2029-03-14 ]
              TpmProtected : YES
          DeviceAuthStatus : FAILED. Device is either disabled or deleted
# Tenant Details
                    MdmUrl : (blank)
# SSO State
                AzureAdPrt : NO
            Attempt Status : 0xc000006d
         Server Error Code : invalid_grant
  Server Error Description : AADSTS50155: Device authentication failed.
# Diagnostic Data
      Last HostName Update : SUCCESS   Client Time : 2022-10-03

Read line by line, that output tells the whole story:

LineWhat it means
AzureAdJoined : YESThe laptop believes it's hybrid joined. This is only its local opinion.
DeviceAuthStatus : FAILEDEntra rejects that belief. The device object it's claiming is gone or disabled.
Cert valid from 2019The identity dates from the original join, years ago.
Last device write 2022The last time this device successfully updated its Entra object. It had been quietly broken for a long time before anyone noticed.
AADSTS50155No PRT because of device authentication, not the user's password.
MdmUrl blankNo working Intune link from the device's point of view.

So the diagnosis: the laptop and Entra disagreed about who the laptop was. The blank join type in Entra was the symptom of an object that had already drifted out of sync. Deleting it didn't cause the problem, but it did make it final, because the laptop was now presenting a device ID with no object behind it at all.

06Why not wipe, retire or Fresh Start?

Every one of those acts on the wrong record.

The Intune record wasn't the problem. It was a downstream casualty. The broken thing was the join state on the laptop, and none of the Intune actions touch that without also destroying something the user needs.

ActionWhat it doesHere?
WipeFactory reset. User data gone.No
Fresh StartReinstalls Windows and strips apps. Not meant for hybrid-joined devices.No
RetireRemoves Intune profiles, certs and apps. Keeps user data. Doesn't touch the join.Doesn't fix it
Reset the joinDrops the stale identity locally and lets the device re-register. No user data touched.Yes

07The fix, step by step

Clear the stale identity on both sides, re-run the join, and let the chain rebuild itself.

1. Leave, on the laptop (elevated):

dsregcmd /leave
dsregcmd /status      # expect AzureAdJoined : NO

2. Clear the old cert from AD (on a DC or anywhere with RSAT; the AD module won't be on the laptop). After the leave, the laptop no longer has the private key that matches this cert. Leaving it on the object risks Entra Connect syncing a dead identity back up.

Set-ADComputer WS-EXAMPLE01 -Clear userCertificate

3. Reboot, sign in, and run the join task (elevated on the laptop, on the corporate network or VPN):

schtasks /run /tn "\Microsoft\Windows\Workplace Join\Automatic-Device-Join"

Then confirm the new cert reached AD. It prints as a long column of byte values, which is fine; you're only checking that something is there.

Get-ADComputer WS-EXAMPLE01 -Properties userCertificate |
  Select-Object -ExpandProperty userCertificate

AzureAdJoined : NO here is expected

This is the gap between pass 1 and pass 2 in the sequence diagram. The cert is in AD, but Entra hasn't heard about it yet. Don't start troubleshooting; sync first.

4. Sync (on the Entra Connect server):

Start-ADSyncSyncCycle -PolicyType Delta

The device reappears in Entra as Microsoft Entra hybrid joined, with Registered showing Pending.

5. Run the join task again to complete pass 2, then check:

dsregcmd /status | findstr /i "AzureAdJoined DeviceAuthStatus AzureAdPrt"
             AzureAdJoined : YES
          DeviceAuthStatus : SUCCESS
                AzureAdPrt : NO      # run as the local admin, so NO is correct

6. Have the user sign out fully and back in. Lock and unlock isn't enough. Then check again in her session.

STATE AFTER EACH STEP JOINEDDEV AUTHPRTINTUNE 0 · BeforeAADSTS50155 on every sign-in YES? FAILED NO ORPHAN 1 · dsregcmd /leavedrops the stale local identity NO — NO ORPHAN 2 · Clear userCertificateold cert can't sync back up NO — NO ORPHAN 3 · Reboot + join tasknew cert written to AD (pass 1) NO — NO ORPHAN 4 · Entra Connect syncobject back in Entra, Registered: Pending PENDING — NO ORPHAN 5 · Join task againregistration completes (pass 2) YES SUCCESS NO* ORPHAN 6 · User signs out and inPRT issued in her session YES SUCCESS YES ORPHAN 7 · GPO auto-enroll (+3 min)new Intune record, MDM written back YES SUCCESS YES ENROLLED * Checked from the local admin's elevated shell. A local account never gets a PRT; only the user's session counts.
Watch the chain rebuild in order. Join comes back, then device auth, then the PRT, and only then Intune. Each column turns green only after the one to its left. Nothing on the Intune side was touched by hand.

08Proving it was fixed

Validate each link, in the user's session, not the admin's.

PS C:\Users\user> dsregcmd /status | Select-String "SSO State" -Context 0,10
                AzureAdPrt : YES
      AzureAdPrtUpdateTime : 2026-01-12 18:02 UTC
      AzureAdPrtExpiryTime : 2026-01-26 18:02 UTC     # 14 days, renews on its own
    Executing Account Name : CONTOSO\user
               KeySignTest : PASSED

Two things went away with the deleted Entra object and needed putting back:

# BitLocker: re-escrow the recovery key to the new object
$kp = (Get-BitLockerVolume C:).KeyProtector | ? KeyProtectorType -eq RecoveryPassword
BackupToAAD-BitLockerKeyProtector -MountPoint C: -KeyProtectorId $kp.KeyProtectorId

# LAPS: repopulates once Intune policy lands; nudge it with
Invoke-LapsPolicyProcessing

One more thing: if LAPS manages the local admin account you've been using all afternoon, its password rotates as soon as policy applies. Retrieve the new one from Entra before you need it.

09"Why are there two devices in Entra?"

The question everyone asks at the end, and the one object you must not clean up.

One laptop one TPM, one serial, one Windows install hybrid join hash imported WS-EXAMPLE01 · hybrid joined The real device: device auth, PRT, compliance, BitLocker keys, LAPS. This is what we fixed. 5CG0XXXXXX · serial-named Autopilot placeholder. Never signs in, so OS is "Unknown". Leave it alone.
Not a duplicate. When a hardware hash is imported into Windows Autopilot, Entra creates an object named after the serial number. It holds the device's Autopilot registration for future resets and has nothing to do with sign-in.

In this case the Autopilot page showed the laptop with Profile status: Not assigned and no group tag, which means it was registered in some earlier bulk import but Autopilot isn't actively doing anything for it. Deleting it is harmless to today's problem, but it's a fleet decision (does this organisation use Autopilot for reimages or not?), not something to tidy up in the middle of a ticket.

10The confusions, laid out

Every one of these came up while this ticket was being worked.

Myth

A device object with a blank join type is junk and can be deleted.

Reality

It's usually a live device whose registration drifted. Check dsregcmd /status on the machine first. Deleting it makes device-auth failure certain.

Myth

Device auth is broken, so the laptop needs a wipe or Fresh Start.

Reality

The fault is in the join state, not the OS or the data. dsregcmd /leave and a re-join fix it without touching a file.

Myth

AzureAdJoined : NO right after running the join task means the join failed.

Reality

In a managed tenant it's the gap between pass 1 and pass 2. Check the cert landed in AD, run a sync, run the task again.

Myth

AzureAdPrt : NO in my admin shell means the user still has no PRT.

Reality

The PRT is per user. A local admin never gets one. Check Executing Account Name and run it in the user's own session.

  • Symptom: every M365 app fails; "device authentication failed"; the register prompt errors out.
  • Root cause: the laptop's hybrid join identity no longer matched any Entra device object (AADSTS50155), so no PRT could be issued.
  • Fix: dsregcmd /leave → clear userCertificate in AD → join task → Entra Connect sync → join task → user signs out and in.
  • Validated: DeviceAuthStatus : SUCCESS, AzureAdPrt : YES in the user session, Intune re-enrolled by itself, BitLocker key re-escrowed.
  • Not touched: user data, the OS, the Autopilot object.

The one-line model

Device identity comes first, the user's PRT is issued on top of it, and Intune is built on the PRT. When every app fails at once, start at dsregcmd /status and fix the first broken link. Everything downstream rebuilds itself.

Sources & further reading

Anonymised from real support work. Device names, serial numbers, IDs, tenant details and account names have been changed.

Filed under
Endpoint Security › Hardening & compliance
Browse this part of the knowledge base.
Related

Comments

Questions or corrections welcome. Sign in with GitHub to join the thread.