Black Friday sale: an extra 40% off every course until Monday, November 30.New Year sale: an extra 30% off every course until Friday, January 1.Memorial Day sale: an extra 25% off every course until Monday, May 31.SysAdmin Day sale: an extra 25% off every course until Sunday, August 1.Back to School sale: an extra 25% off every course until Sunday, August 22.Labor Day sale: an extra 25% off every course until Monday, September 6.Black Friday sale: an extra 40% off every course until Monday, November 29.New Year sale: an extra 30% off every course until Saturday, January 1.Choose your certification →

Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

6.1.2. Extending Compliance with PowerShell

💡 First Principle: Built-in compliance settings can only check what Microsoft thought to include. Custom compliance lets the device measure anything a script can read, and keeps the judgment in Intune: the script reports facts as JSON, and a rules file you wrote decides whether those facts are compliant. Separating measuring from judging is why the same script output can feed Conditional Access exactly like a built-in setting, and also why the script never fixes anything.

Suppose your security team requires a specific endpoint agent to be running at version 7.2 or later, and that a legacy protocol is disabled in the registry. No compliance policy setting covers either. With custom compliance you write a discovery script that reads both values, return them as JSON, and upload rules that say "AgentVersion must be at least 7.2" and "LegacyProtocolEnabled must be false". A device that fails either rule is marked noncompliant, and a Conditional Access policy that requires compliant devices then blocks it.

How the pieces fit. First upload the script at Endpoint security > Device compliance > Scripts > Add, choosing the platform. Then create a compliance policy, select the script, and upload the JSON rules file. Each policy supports one script, and each script can be used by only one policy, though one script can discover many settings. You can't delete a script that's still assigned to a policy.

On Windows the discovery script is PowerShell and must return compressed single-line JSON:

$hash = @{ AgentVersion = "7.4.1"; LegacyProtocolEnabled = $false }
return $hash | ConvertTo-Json -Compress

Each rule in the JSON file names the setting and how to judge it:

{
  "SettingName": "AgentVersion",
  "Operator": "GreaterEquals",
  "DataType": "Version",
  "Operand": "7.2",
  "MoreInfoUrl": "https://contoso.com/agent",
  "RemediationStrings": [
    { "Language": "en_US", "Title": "Endpoint agent out of date",
      "Description": "Update the agent. Current version: {ActualValue}." }
  ]
}

SettingName is case-sensitive and must match the script output exactly. The operators are IsEquals, NotEquals, GreaterThan, GreaterEquals, LessThan and LessEquals, and the data types are Boolean, Int64, Double, String, DateTime and Version. Every rule needs at least one en_US remediation string, and users see those strings in the Company Portal when the device is noncompliant, with {ActualValue} filled in.

Platforms. Custom compliance supports Windows (not Home), macOS (new in service release 2607, July 2026) and Linux (Ubuntu Desktop 24.04 or 26.04 LTS, RHEL 9 and RHEL 10). Windows scripts are PowerShell, macOS scripts are Bash, and Linux scripts can use any interpreter named in the shebang. On Linux the script runs in the user's context, so it can't check settings that need elevation.

LimitValue
Script size and script output1 MB each
Run time10 minutes on Windows and macOS, 5 minutes on Linux
Rules file100 rules, 100 KB
Windows discovery cadenceEvery eight hours through the Intune Management Extension

Timing and troubleshooting. On Windows, the Intune Management Extension checks for new or changed scripts and runs discovery every eight hours. Check Compliance reruns scripts but doesn't fetch new ones, and push notifications can't trigger custom compliance on demand. So after a user fixes the problem, the device can take up to eight hours to show as compliant. Error codes narrow down what broke: 65007 means the script returned a failure, 65008 a setting is missing from the script result, 65009 the JSON for a setting is invalid, and 65010 the data type is wrong. Per-setting results appear in Reports > Device compliance > Reports > Noncompliant devices and settings. The script upload workflow doesn't support scope tags, so you need the default scope tag to create, edit or view discovery scripts.

⚠️ Exam Trap: A custom compliance script doesn't fix the problem it detects, even though it runs PowerShell on the device. It only reports: its JSON output is judged against your rules, and the device is marked compliant or not. If the requirement is to correct the setting automatically, the answer is Remediations (6.2.3), a detection and remediation script pair. Custom compliance is the answer when the requirement is to block access until the setting is right.

Reflection Question: A user fixed the registry value that made their laptop noncompliant, ran Check Compliance, and still can't open Outlook an hour later. Explain why, and what would have to change about your design if the business needs the value corrected without the user's involvement.

See how it connects
Alvin Varughese
Written byAlvin Varughese
Founder•26 professional certifications earned