Skip to main content
Compliance & SyncIntune custom compliance code

Fix Intune Error 65007

The custom compliance script returned failure — the detection script exited non-zero or reported failure, so the setting was not evaluated.

Open the log below first. It is the quickest way to confirm which of the causes applies before you change anything.

IntuneManagementExtension.log

Folder: C:\ProgramData\Microsoft\IntuneManagementExtension\Logs\

Also check: AgentExecutor.log · Detection script output (the JSON the script returned) · Device compliance report (Intune admin center > Reports > Device compliance > Noncompliant devices and settings)

Root causes

  • The detection script exits non-zero even when detection succeeds.
  • The script throws before returning its JSON result.
  • The script runs in the wrong context — user instead of SYSTEM — and cannot read the setting.
  • The script depends on a module or path that is not present on the device.

Step-by-step remediation

  1. In the Intune admin center open Reports > Device compliance > Noncompliant devices and settings and find the device and setting.
  2. Run the detection script locally in the same context Intune uses (SYSTEM for device scripts) and read its exit code and output.
  3. On Windows, end the PowerShell script with `return $hash | ConvertTo-Json -Compress` so the result is returned as JSON.
  4. Fix the script so it exits 0 and returns valid JSON when the setting is present, then sync the device and re-check the report.

For the full diagnosis around this error, read Intune Compliance Policy Not Evaluating: End-to-End Troubleshooting Checklist.

Tighten the rollout around it

Enrollment and compliance errors usually trace back to rollout design and device permissions. See how the endpoint privilege management tools compare, and start the next import from a clean Autopilot hardware-hash file.

Compare Intune endpoint privilege management tools

Other Compliance & Sync errors with their own runbooks.

Search all 46 error codes