How custom compliance scripts work
A custom compliance policy requires two components:| Component | Description |
|---|---|
Detection script (.ps1) | PowerShell script that runs on the device and returns a JSON object with discovered settings |
Compliance JSON (.json) | JSON file uploaded to Intune that defines the rules and expected values to evaluate against the script output |
Unlike Proactive Remediations, compliance detection scripts do not use exit codes to signal compliant/non-compliant state. Instead, they output a JSON object that Intune evaluates against your compliance rules JSON. Exit code
0 indicates the script ran successfully; a non-zero exit means the script itself failed to run.Adding detection scripts to Intune
Upload the detection script
Sign into the Intune admin center and navigate to Endpoint security > Device compliance > Scripts > Add > Windows 10 and later.On the Basics tab, provide a name. On Settings, paste or upload your detection script.
Configure script settings
For Windows scripts, configure the following options:
- Run this script using the logged-on credentials — set to
Yesif the script needs user context (leave asNofor system-level checks) - Enforce script signature check — enable if your scripts are signed
- Run script in 64-bit PowerShell Host — set to
Yesto avoid 32-bit registry redirection issues
Create a custom compliance policy
Go to Devices > Compliance > Create policy > Windows 10 and later.On the Compliance settings tab, expand Custom Compliance and:
- Set Custom compliance to
Require - Select the detection script you uploaded
- Upload the compliance JSON file
Available compliance scripts
Cisco Umbrella
Cisco Umbrella
Checks that the Cisco Umbrella (Cisco Secure Client) agent service is running and configured to start automatically.Service name: Compliance JSON rules (save as
csc_umbrellaagentWhat it checks:ServiceState— service status (expected value:4= Running)ServiceStartupMode— service start type (expected value:3= Manual/Automatic depending on your JSON rule)
Detect-Cisco-Umbrella.ps1
.json and upload to Intune):Netskope
Netskope
Checks that the Netskope client agent service (Compliance JSON rules:
stAgentSvc) is running and configured to start automatically.Service name: stAgentSvcWhat it checks:ServiceState— service status (expected value:4= Running)ServiceStartupMode— service start type (expected value:2= Automatic)
Detect-Netskope.ps1
Zscaler
Zscaler
Verifies that the Zscaler Client Connector is actively routing traffic through the Zscaler proxy. Rather than checking a service state, this script connects to Compliance JSON rules:
http://ip.zscaler.com/ and reads the response to determine whether the device is proxied through Zscaler.What it checks:ZScalerStatus— string value read from the Zscaler IP check page. A device passing traffic through Zscaler returns a confirmation string; a device not using Zscaler returns a different message.
Detect-Zscaler.ps1
This script uses
Invoke-WebRequest with Internet Explorer’s ParsedHtml DOM parser (only available in Windows PowerShell 5.x). It requires the device to have network access to ip.zscaler.com to evaluate compliance. Devices that are offline or behind a non-Zscaler proxy may report as non-compliant.Service status value reference
PowerShell reports service status and start type as integer enum values. Use this reference when writing your compliance JSON rules:| Value | Status meaning | StartType meaning |
|---|---|---|
1 | Stopped | Boot |
2 | StartPending | System |
3 | StopPending | Automatic |
4 | Running | Manual |
5 | ContinuePending | Disabled |
6 | PausePending | — |
7 | Paused | — |
