A new laptop finishes Windows Autopilot. The user reaches the desktop, signs in, and starts working. In the Microsoft Intune admin center the device appears as enrolled and compliant. Every box on the deployment checklist is ticked.
Three weeks later a security analyst runs a hunting query across the estate. That laptop is not in the results. It was never in the results. The device has been enrolled, managed and compliant the whole time, and it has never sent a single byte of sensor data to Microsoft Defender for Endpoint.
Enrolling a device in Intune and onboarding it to Microsoft Defender for Endpoint (MDE) are two separate operations with two separate success signals. Onboarding is driven by a policy, and the sensor that acts on that policy will not complete its first start until the out-of-box experience (OOBE) has finished. That is documented behaviour, not a bug. The device-side truth lives in one registry value that Microsoft documents as 0 for not onboarded and 1 for onboarded, plus the state of the Sense service. Neither of those is what an Intune compliance dashboard shows you, so a device can sit enrolled but unprotected indefinitely unless you go looking. The companion script reads that surface and tells you which of the three states the device is actually in.
The problem: enrolled in Intune, invisible to Defender
Autopilot gives you a satisfying green tick at the end of provisioning. That tick means the device joined Microsoft Entra ID, enrolled with Intune, and completed the Enrollment Status Page. It does not mean the device is protected.
Microsoft Defender for Endpoint is not switched on by enrollment. It is switched on by onboarding, which is a distinct step. Microsoft describes it plainly: "Device onboarding configures your managed devices to communicate with Defender for Endpoint" and "Device onboarding is a one-time action per device". Until that action completes, the sensor has no tenant to talk to.
The gap is easy to miss because the two states are reported in different places. Enrollment shows up in Intune. Onboarding shows up in the Microsoft Defender portal device inventory.
The timings that make the gap invisible
The published expectations are wide enough that a genuinely broken device looks like a slow one for days. These are Microsoft's own figures, drawn from five different articles.
| Stage | Documented expectation | Why it matters |
|---|---|---|
| Connector status refresh in Intune | Connection status can take up to 15 minutes to update | An admin who checks immediately after enabling it sees the old value |
| EDR policy deployed to portal visibility | After 15 to 30 minutes, devices should appear in the Defender portal device inventory | This is the happy-path figure most people remember |
| Onboarding completed on the device | Event 11 is logged, then "it might take several hours for the device to appear in the portal" | Several hours of legitimate silence hides a real failure |
| Failure threshold | "If you've completed the onboarding process and don't see devices in the Devices list after an hour, it might indicate an onboarding or connectivity problem" | One hour is Microsoft's own suspicion threshold |
| Group Policy onboarding route | "It can take several days for devices to start showing on the Devices list" | Covers policy distribution, user logon, and the endpoint starting to report |
Read that table again. Somewhere between fifteen minutes and several days, silence is normal. That is exactly the window in which a device that will never onboard looks identical to one that is about to.
Why it happens: onboarding is a second handshake, and OOBE gates it
To understand why the failure mode exists, follow the chain. There are six links, and each one can break on its own.
- The connector. A service-to-service connection is created between Intune and Defender for Endpoint. Microsoft calls this a one-time setup per tenant.
- The onboarding package. Microsoft states that "when you establish the service connection, Intune automatically receives an onboarding configuration package from Microsoft Defender for Endpoint". Without the connector, Intune has no package to hand out.
- The policy. An Endpoint detection and response (EDR) policy carries that package to the device. It has to be assigned to something.
- The policy landing. The management channel writes the onboarding blob into a registry key on the device.
- The sensor first start. The Sense service reads the blob, starts, and writes its own status key. Microsoft documents this exactly: "When the SENSE service starts for the first time, it writes onboarding status to the registry location
HKLM\SOFTWARE\Microsoft\Windows Advanced Threat Protection\Status". - The registration. The sensor registers with the authentication service and starts uploading sensor data. Only now does the device appear in the Defender portal.
Link five is where Autopilot specifically bites.
The sensor waits for OOBE, on purpose
Microsoft has a section titled "Confirming onboarding of newly built devices" that describes this scenario almost word for word. The onboarding package is deployed to newly built devices. The sensor does not start because the out-of-box experience or first user logon has not completed. The device is turned off or restarted before the end user performs a first logon. And then the payoff line: "in this scenario, the SENSE service won't start automatically even though onboarding package was deployed".
The sensor logs its own opinion about this. Three of its event IDs exist purely to report whether Windows Welcome has finished.
| Event ID | Documented message | Documented description |
|---|---|---|
| 18 | OOBE (Windows Welcome) is completed. | Service will only start after any Windows updates have finished installing. |
| 19 | OOBE (Windows Welcome) hasn't yet completed. | Service will only start after any Windows updates finish installing. If this persists after a restart, ensure all Windows updates are installed. |
| 20 | Can't wait for OOBE (Windows Welcome) to complete. Failure code: variable. | Internal error. If it persists after a restart, ensure all Windows updates are installed. |
The two halves can disagree with each other
Because onboarding is a multi-step handshake, the sensor can be running while onboarding has not completed, or onboarded while the service is not running. Microsoft documents both as known non-compliance cases.
| Symptom | Documented cause | Documented action |
|---|---|---|
Compliant by SenseIsRunning, non-compliant by OrgId, Onboarding and OnboardingState | "Check that user passed OOBE after Windows installation or upgrade. During OOBE onboarding couldn't be completed but SENSE is running already." | Wait for OOBE to complete |
Compliant by OrgId, Onboarding and OnboardingState, non-compliant by SenseIsRunning | The Sense service startup type is set as delayed start, so a device-management session at system start can report it as not running | "The issue should automatically be fixed within 24 hours" |
| Device is non-compliant | Onboarding and offboarding policies both reaching the device | Ensure they are not deployed on the same device at the same time |
The registry surface
Two separate parent keys are involved. Confusing them is the single most common reason a verification script reports the wrong answer. One is written by the management channel. The other is written by the sensor.
The management side first. This is where the onboarding blob arrives, and where the documented configuration values live.
| Value | Documented meaning | What to look for |
|---|---|---|
| The key itself | Microsoft lists a documented failure cause as "Microsoft Defender for Endpoint Policy registry key doesn't exist or the OMA DM client doesn't have permissions to write to it". Onboarding-script error 10 is "Onboarding data couldn't be written to registry" and points at this same key. | If the key is absent, no onboarding policy has ever reached the device |
AllowSampleCollection | REG_DWORD. 0 means sample sharing is not allowed from the device. 1 means sharing of all file types is allowed, and 1 is the default if the value does not exist. | Set by the EDR policy Sample Sharing setting |
ForceDefenderPassiveMode | REG_DWORD set to 1 to place Defender Antivirus in passive mode on Windows Server. Microsoft says it must be set before onboarding the device. | Server-side only, and tamper protection changes its behaviour once active mode is reached |
Now the sensor side. This key does not exist until the sensor has started at least once, which makes its absence a diagnostic in itself.
| Property | Documented values | Reading |
|---|---|---|
OnboardingState | Microsoft documents the health state through the WindowsAdvancedThreatProtection configuration service provider (CSP): 0 (default) is Not onboarded, 1 is Onboarded. Onboarding-script error 40 is "SENSE service onboarding status isn't set to 1", which is the same semantics. | 1 is the only value that means protected |
OrgId | The CSP exposes HealthState/OrgId as "String that represents the OrgID". | Presence proves the sensor has a tenant to report to. Never paste this value into a ticket |
| The key itself | Written by the SENSE service on first start. Onboarding-script error 35 is "The script failed to find needed onboarding status registry value". | An absent key means the sensor has never completed a first start |
Antivirus mode is a different question entirely
People conflate "Defender is running" with "Defender for Endpoint is onboarded". They are unrelated measurements. Microsoft Defender Antivirus runs in one of three states, and the state depends partly on whether the device is onboarded.
| Antivirus solution on the device | Onboarded to Defender for Endpoint? | Documented Defender Antivirus state |
|---|---|---|
| Microsoft Defender Antivirus | Yes | Active mode |
| Microsoft Defender Antivirus | No | Active mode |
| A non-Microsoft antivirus solution | Yes | Passive mode, automatically |
| A non-Microsoft antivirus solution | No | Disabled mode, automatically, on Windows 10 and Windows 11 |
Note the top two rows. Defender Antivirus in active mode tells you nothing about onboarding. Microsoft also states that "in general, Microsoft Defender Antivirus can be set to passive mode only on endpoints that are onboarded to Defender for Endpoint". That makes passive mode a weak positive signal and active mode no signal at all.
One more Autopilot-adjacent trap
The sensor is a Windows capability, not a downloaded agent. If it is missing, onboarding cannot succeed no matter how well the policy is written. Microsoft documents onboarding-script error 15 as covering exactly this: "The SENSE Feature on Demand (FoD) may not be installed", checked with a read-only DISM query against capability name Microsoft.Windows.Sense.Client~~~~. The CSP article carries the same warning from the other direction: "Windows 11 Home devices that have been upgraded to one of the below mentioned applicable editions might require you to run" the DISM add-capability command before onboarding. Any Autopilot fleet that includes edition-upgraded hardware should expect to meet this.
How to verify: five checks on the device, two in the portals
Verification has to be positive. "Nothing in the log" is not a pass, because a device whose sensor never started has an empty log by definition.
Checks 1 and 2: the registry state and the service
These two together answer most cases. Run them elevated, because both surfaces need administrator rights and read as empty otherwise.
Check 3: the antivirus side
Microsoft's documented method for reading the antivirus mode is a single property. The values you should see when antivirus protection is enabled are Normal, Passive, or EDR Block Mode. Tamper protection is read from the same object, where a value of true means it is enabled.
Check 4: the sensor event channel
The sensor writes to its own dedicated channel. In Event Viewer, open Applications and Services Logs › Microsoft › Windows › SENSE and select Operational. Microsoft notes that SENSE is the internal name for the behavioural sensor that powers Defender for Endpoint. The full channel name for Get-WinEvent is below.
That sequence is the story of a device that finished provisioning, waited for Windows Welcome, then onboarded. Event 11 is the one you are hunting for. Event 4 following it is the proof it is actually talking.
Here is the catalog for the same channel, restricted to the events that bear on onboarding. Microsoft publishes many more, covering quotas, cloud configuration and response commands.
| Event ID | Documented message | What it tells you |
|---|---|---|
| 1 | Service started (Version variable) | Normal. Occurs at startup, shutdown and during onboarding |
| 2 | Service shutdown | Normal. Occurs on shutdown or offboarding |
| 3 | Service failed to start. Failure code: variable | Read the surrounding events for the cause |
| 4 | Service contacted the server at variable | The sensor is genuinely reporting. Variable is the service URL |
| 5 | Service failed to connect to the server at variable | A connectivity or proxy problem, not an onboarding problem |
| 6 | Service isn't onboarded and no onboarding parameters were found | The policy never landed. Check the Policies registry key |
| 7 | Service failed to read the onboarding parameters. Failure: variable | The blob is there but unusable. Redeploy the configuration package |
| 9 | Service failed to change its start type. Failure code: variable | During onboarding, this means the device did not onboard correctly |
| 10 | Service failed to persist the onboarding information. Failure code: variable | A registry write failed. Re-run onboarding |
| 11 | Onboarding or reonboarding of Defender for Endpoint service completed | Success. The portal may still take several hours |
| 13 | Device ID calculated: variable | Normal operating notification |
| 17 | Failed to change the Connected User Experiences and Telemetry service location | A diagnostic data service problem. Re-run onboarding |
| 18 | OOBE (Windows Welcome) is completed | The gate has opened |
| 19 | OOBE (Windows Welcome) hasn't yet completed | The gate is closed. Expected on a mid-provisioning device |
| 20 | Can't wait for OOBE (Windows Welcome) to complete. Failure code: variable | Internal error. Confirm all Windows updates are installed |
| 25 | Failed to reset health status in the registry. Failure code: variable | Reports to the portal but may not appear registered in the registry |
| 26 | Failed to set the onboarding status in the registry. Failure code: variable | Same shape as 25. Your registry check will lie to you |
| 27 | Failed to enable SENSE aware mode in Microsoft Defender Antivirus. Onboarding process failed | The antivirus handoff failed. Confirm real-time protection is running |
| 33 | Failed to persist SENSE GUID. Failure code: variable | The same device might appear twice in the portal |
| 44 | Offboarding of Defender for Endpoint service completed | Something offboarded this device. Find out what |
| 68 | The start type of the service is unexpected. Service name, actual start type, expected start type | An external service dependency has drifted. Fix its start type |
| 69 | The service is stopped. Service name: variable | A dependency the sensor needs is not running |
| 84 | Set Microsoft Defender Antivirus running mode. Force passive mode: variable, result code: variable | Normal. This is the active or passive decision being applied |
| 1806 | CSP: Get Onboarding State value complete. Result, IsDefault | The MDM channel reading the onboarding state |
| 1810 | CSP: Onboarding process. Started | The MDM-driven onboarding flow beginning |
| 1812 | CSP: Onboarding process. Write Onboarding blob complete. Result | The blob reached the registry |
| 1813 | CSP: Onboarding process. The service started successfully | The sensor was started as part of the flow |
| 1831 | CSP: Get Sense is running. Service is configured as delay-start, and hasn't started yet | The documented false negative behind non-compliance case 2 |
There is a second, separate event surface if you onboarded with a script rather than a policy. It is not in the SENSE channel at all. Microsoft directs you to Event Viewer, then Windows Logs › Application, filtered to the source below.
| Event ID | Documented error type | Documented resolution |
|---|---|---|
| 5 | Offboarding data was found but couldn't be deleted | Check permissions on the Policies key |
| 10 | Onboarding data couldn't be written to registry | Check permissions on the Policies key, and confirm the script ran as administrator |
| 15 | Failed to start SENSE service | Check that sc query sense is not in a pending state. Error 577 or 1058 means the antivirus ELAM driver is disabled. It can also mean the SENSE Feature on Demand is not installed |
| 30 | The script failed to wait for the service to start running | Review the SENSE Operational channel |
| 35 | The script failed to find needed onboarding status registry value | Check the Status key manually |
| 40 | SENSE service onboarding status isn't set to 1 | The service failed to onboard properly. Review the SENSE Operational channel |
| 65 | Insufficient privileges | Run the script again with administrator privileges |
| 70 | Offboarding script is for a different organization | Get an offboarding script for the correct organization |
The antivirus side has its own channel again, distinct from both of the above. It sits under Applications and Services Logs › Microsoft › Windows › Windows Defender › Operational.
| Event ID | Symbolic name | What it proves |
|---|---|---|
| 1150 | MALWAREPROTECTION_SERVICE_HEALTHY | The antivirus client is up and running in a healthy state. Reported hourly |
| 1151 | MALWAREPROTECTION_SERVICE_HEALTH_REPORT | Full health report, including real-time protection and behaviour monitoring state |
| 2000 | MALWAREPROTECTION_SIGNATURE_UPDATED | Signatures updated successfully. Absence on a new device is a first-boot symptom |
| 2001 | MALWAREPROTECTION_SIGNATURE_UPDATE_FAILED | The security intelligence update failed |
Check 5, and the two portal checks
Microsoft's documented end-to-end confirmation is a detection test, which produces a real alert rather than a status field. After onboarding, "you can choose to run a detection test to verify that a device is properly onboarded to the service". That is the only check that exercises the whole chain.
On the tenant side there are exactly two places to look. First, the Intune view of onboarding status.
Microsoft describes the success indicators there as devices appearing in the Defender portal device inventory, an EDR Onboarding Status of "Successfully onboarded", and risk levels appearing in device compliance reports. Reading that tab needs Read permission for Microsoft Defender Advanced Threat Protection in Intune role-based access control, which is why some admins have never seen it populated.
The fix: connector first, then policy, then assignment
Order matters here. Creating the policy before the connector produces a policy that cannot use the automatic package, and nothing in the interface explains why.
Step 1: confirm or create the connector
- Sign in to the Microsoft Intune admin center and select Endpoint security then Defender for Endpoint.
- Read Connection status. If it shows Enabled, the services are already connected and you can skip to step 2. If it shows Unavailable, continue.
- Scroll to the bottom of the Defender for Endpoint page and select Open the Defender Security Center. If you are already connected, that link instead reads Open the Defender for Endpoint admin console.
- In the Microsoft Defender portal, go to System then Settings then Endpoints then General then Advanced features.
- Find Intune connection, toggle it to On, then select Save preferences.
- Return to Intune. Connection status should now show Enabled. Microsoft notes it can take up to 15 minutes to update.
While you are on the Intune Defender for Endpoint page, also set Connect Windows devices to Defender for Endpoint to On under Compliance policy evaluation. Microsoft warns that enabling it connects all applicable devices you currently manage, plus future enrollments, for compliance evaluation. Do that deliberately, not by accident.
Step 2: create the Endpoint detection and response policy
- Go to Endpoint security then Endpoint detection and response then the Summary tab, and select Create Policy.
- Set Platform to Windows and Profile to Endpoint detection and response. Select Create.
- Enter a descriptive name and select Next.
- For Microsoft Defender for Endpoint client configuration package type, choose Auto from connector. Microsoft marks this as recommended because it uses the automatic onboarding package. The Onboard option, where you paste the blob content yourself, is documented as being for disconnected environments.
- Set Sample Sharing to All or None. Microsoft notes that None can reduce detection capabilities.
- Leave Telemetry Reporting Frequency alone. Microsoft states it is deprecated and does not affect new devices, and remains visible only for older policy compatibility.
- Add scope tags if you use them, then select Next.
- On Assignments, choose device groups. Microsoft is explicit about the difference: device groups are recommended for immediate deployment, while user groups require user sign-in before the policy applies.
- Review + create.
Step 8 is the one that quietly creates enrolled-but-unprotected devices in an Autopilot fleet. A user-group assignment cannot apply until somebody signs in, and a device that is provisioned, shelved, and later handed to a different person may never receive it.
The Group Policy and local script routes
Autopilot-provisioned, Entra-joined clients have no Group Policy to receive, so this is not the route for them. It matters anyway, because most estates are mixed, and because the mechanism shows what the Intune policy is doing under the covers. Microsoft's Group Policy onboarding article is scoped to Windows Servers, and it works by running the onboarding script as an immediate scheduled task.
- Download the Group Policy configuration package from the Microsoft Defender portal at System then Settings then Endpoints then Device management then Onboarding, with Deployment method set to Group policy.
- Extract it to a shared, read-only location. You should have a folder called OptionalParamsPolicy and the file WindowsDefenderATPOnboardingScript.cmd.
- In the Group Policy Management Editor, go to Computer configuration then Preferences then Control panel settings.
- Right-click Scheduled tasks, point to New, then select Immediate Task (At least Windows 7).
- On the General tab, under Security options, select Change User or Group, type SYSTEM, then Check Names and OK.
- Select Run whether user is logged on or not and tick Run with highest privileges.
- On the Actions tab, add a Start a program action pointing at the UNC path of the shared WindowsDefenderATPOnboardingScript.cmd, using the file server's fully qualified domain name.
- Link the Group Policy Object to the target organisational unit.
Sample collection on that route is an administrative template rather than a registry edit. Copy AtpConfiguration.admx into C:\Windows\PolicyDefinitions and AtpConfiguration.adml into C:\Windows\PolicyDefinitions\en-US, or the equivalent central store paths, then find the setting at Computer Configuration then Policies then Administrative templates then Windows components then Windows Defender ATP. Microsoft notes that if you do not set a value, the default is to enable sample collection.
For one-off testing there is the local script. Microsoft is firm about its scope: "You should use it on a limited number of devices only (10 devices or less)." Download GatewayWindowsDefenderATPOnboardingPackage.zip, extract WindowsDefenderATPLocalOnboardingScript.cmd, and run it from an elevated command prompt. Microsoft also lists this as the last-resort diagnostic when Intune onboarding will not work: "If none of the event logs and troubleshooting steps work, download the Local script from the Device management section of the portal, and run it in an elevated command prompt."
./Device/Vendor/MSFT/WindowsAdvancedThreatProtection/Onboarding. It works, but the health-state nodes on the same CSP are read-only, and Microsoft says so twice. "The Health Status for onboarded devices policy uses read-only properties and can't be remediated", and a documented Intune error cause is "An attempt to remediate by read-only property". If you built something that tries to set SenseIsRunning, OnboardingState or OrgId, that is your bug.Proof it worked: what a genuinely onboarded device looks like
The companion script collects every surface above in one pass and refuses to give a verdict when a check could not be completed. Below is a real run on a healthy device, trimmed for length, with the device name redacted.
The verdicts the script distinguishes are the point of the whole exercise.
| Verdict | Signal combination | What to do |
|---|---|---|
| ONBOARDED | OnboardingState 1, org ID present, Sense running, no failure events | Nothing. Confirm in the Defender portal device inventory |
| ONBOARDED-BUT-NOT-REPORTING | OnboardingState 1, org ID present, Sense not running | Onboarding succeeded but nothing is being sent. Check the delayed-start case and events 68 and 69 |
| NOT ONBOARDED | Status key or OnboardingState missing, or OnboardingState 0 | Look at the policy, not the sensor. Then look at events 18 and 19 |
| INCONCLUSIVE | A check could not be completed, or the script is not elevated | Fix the read, then re-run. A clean result on a failed read is worse than no result |
| NO SENSOR SURFACE | No Sense service and no Windows Advanced Threat Protection key | Unsupported edition, or the SENSE Feature on Demand is not installed |
To audit a whole Autopilot fleet rather than one device, run the script as an Intune remediation detection script. It exits 0 only for a genuinely onboarded device. It exits 1 for not-onboarded, onboarded-but-not-reporting and inconclusive, and exits 2 when the sensor surface is absent entirely. Cross-reference the non-zero results against the EDR Onboarding Status tab, and the difference between the two lists is your real exposure.
One closing note on scope, because onboarding is not a small switch. Microsoft states that "onboarding to Defender for Endpoint will onboard the device to Data Loss Prevention (DLP), which is also a part of Microsoft 365 compliance". Offboarding is not small either: it "causes the device to stop sending sensor data to Defender for Endpoint, but data from the device, including references to any alerts it has, is retained for up to 6 months".
References
Microsoft official documentation:
- Configure Microsoft Defender for Endpoint with Intune and onboard devices - the connector, the EDR policy, Auto from connector, and the EDR Onboarding Status tab
- Troubleshoot Microsoft Defender for Endpoint onboarding issues - the Status registry key, the WDATPOnboarding script events, the non-compliance cases, and "Confirming onboarding of newly built devices"
- Review events and errors using Event Viewer - the full Microsoft-Windows-SENSE/Operational event catalog
- WindowsAdvancedThreatProtection CSP - OnboardingState 0 and 1, OrgId, SenseIsRunning, and the Onboarding node
- Microsoft Defender Antivirus compatibility with other security products - active, passive and disabled mode, AMRunningMode, and ForceDefenderPassiveMode
- Onboard Windows Servers to Microsoft Defender for Endpoint via Group Policy - the immediate scheduled task route and the ADMX files
- Onboard Windows Servers using a local script - the 10-device limit and AllowSampleCollection
- Onboard Windows devices to Defender for Endpoint using Intune - the read-only health status properties, the offboarding EDR policy path, and the DLP note
- Protect security settings with tamper protection - IsTamperProtected and RealTimeProtectionEnabled
- Microsoft Defender Antivirus event IDs and error codes - the Windows Defender Operational channel and events 1150, 1151, 2000 and 2001
- Get-MpComputerStatus - the property set including AMRunningMode
- Windows Autopilot Enrollment Status Page - what the ESP actually tracks
Community deep dives, each fetched and confirmed on topic before citing:
| Author | Article | Why it is worth reading |
|---|---|---|
| Mattias Melkersen, Rudy Ooms and Ben Whitmore (MSEndpointMgr) | Onboarding modern with Autopilot: Magic trick revealed | Walks the whole Autopilot provisioning sequence phase by phase, and places Defender onboarding in its actual position within the Device Setup order rather than treating it as a standalone task |
| Peter van der Woude | Onboard Windows 10 devices for Windows Defender Advanced Threat Protection | The original OMA-URI onboarding walkthrough with registry verification. Dated 2017 and uses the old product name, so read it for the mechanism rather than the interface |
The companion script for this post is Get-DefenderOnboardingState.ps1. It is read-only, runs on Windows PowerShell 5.1 and PowerShell 7, prompts before installing anything, and never prints your org ID.
Download it from Imran76Awan/Windows-Autopilot-Scripts — no sign-in required. It is read-only: it reports and never changes a device or anything in Intune. Validate it in your own environment before relying on the output.