Skip to main content
Compliance & SyncIntune custom compliance code

Fix Intune Error 65009

Invalid JSON for a discovered setting — the script returned something that is not valid JSON for that setting.

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 script prints extra text — warnings or Write-Host output — alongside the JSON.
  • The JSON is malformed: a trailing comma or an unquoted value.
  • The script returns the setting as a string instead of the JSON value the rule expects.
  • The script file encoding is not UTF-8.

Step-by-step remediation

  1. Run the script locally and capture exactly what it writes to STDOUT — it must be only the JSON.
  2. Remove Write-Host and extra output, and confirm the script file is UTF-8.
  3. End the script with `return $hash | ConvertTo-Json -Compress`.
  4. Validate the JSON against the custom compliance JSON, re-upload, sync 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