Device Compliance Policies
Overview
Device compliance policies define the requirements that devices must meet to be considered compliant. Compliance status can be used with Conditional Access to control access to corporate resources. Graph Endpoint:/deviceManagement/deviceCompliancePoliciesService:
CompliancePolicyServicePermission:
DeviceManagementConfiguration.ReadWrite.All
Supported Operations
| Operation | Method | Description |
|---|---|---|
| List | ListAsync() | Retrieve all compliance policies |
| Get | GetAsync(id) | Retrieve a specific policy by ID |
| Create | CreateAsync(policy) | Create a new compliance policy |
| Update | UpdateAsync(id, policy) | Update an existing policy |
| Delete | DeleteAsync(id) | Delete a compliance policy |
| Get Assignments | GetAssignmentsAsync(id) | Retrieve assignment information |
| Assign | AssignAsync(id, assignments) | Assign policy to groups |
Platform Support
Compliance policies are available for all major device platforms:Windows 10/11
- Operating system version - Minimum and maximum OS version requirements
- BitLocker - Require BitLocker encryption
- Secure Boot - Require Secure Boot to be enabled
- Code integrity - Require code integrity validation
- Microsoft Defender - Antivirus, antispyware, and real-time protection requirements
- Microsoft Defender for Endpoint - Require device to be at or under machine risk score
- Firewall - Require Microsoft Defender Firewall enabled
- Password - Password complexity, length, expiration, and history requirements
- Device security - TPM requirement
- Configuration Manager compliance - Require device compliance from Configuration Manager
macOS
- Operating system version - Minimum and maximum OS version requirements
- Password - Password complexity, length, and expiration requirements
- System integrity protection - Require SIP enabled
- Device security - Firewall and FileVault requirements
- Gatekeeper - Require Gatekeeper enabled
iOS/iPadOS
- Operating system version - Minimum and maximum OS version requirements
- Jailbroken devices - Block jailbroken devices
- Password - Password complexity, length, and expiration requirements
- Device security - Require passcode, Touch ID, Face ID
- Restricted apps - Block specific apps from being installed
- Email profile - Require managed email profile
Android
- Operating system version - Minimum and maximum OS version requirements
- Rooted devices - Block rooted devices
- Google Play Protect - Require Google Play Services, device threat scan, SafetyNet attestation
- Password - Password complexity, length, and expiration requirements
- Device security - Encryption, USB debugging restrictions
- Restricted apps - Block specific apps from being installed
- Company Portal minimum version - Require minimum Company Portal app version
Graph API Details
Compliance Actions
Each compliance policy can include one or more compliance actions that are triggered when a device becomes non-compliant:| Action | Description | Timing |
|---|---|---|
| Mark device non-compliant | Flag the device as non-compliant | Immediately or after grace period |
| Send email to end user | Send notification email to the device user | Scheduled intervals |
| Send push notification | Send Company Portal push notification | Scheduled intervals |
| Remotely lock device | Lock the non-compliant device | After grace period |
| Retire device | Remove company data from the device | After grace period |
Conditional Access Integration
Compliance policies are the foundation of device-based Conditional Access:- Device checks in with Intune and evaluates compliance policies
- Compliance status is written to Entra ID
- Conditional Access policies check device compliance state
- Access to resources is granted or blocked based on compliance
Export/Import
Compliance policies export to:Custom Compliance Scripts
Overview
Custom compliance scripts (also called compliance settings) allow you to evaluate compliance using PowerShell or shell scripts for scenarios not covered by built-in compliance settings. Graph Endpoint:/deviceManagement/deviceComplianceScriptsService:
ComplianceScriptServicePermission:
DeviceManagementConfiguration.ReadWrite.All
Supported Operations
| Operation | Method | Description |
|---|---|---|
| List | ListAsync() | Retrieve all compliance scripts |
| Get | GetAsync(id) | Retrieve a specific script by ID |
Custom compliance scripts support List and Get operations through the AssignmentChecker service. Full CRUD operations may be added in future releases.
Platform Support
- Windows 10/11 - PowerShell scripts (.ps1)
- macOS - Shell scripts (.sh)
- Linux - Shell scripts (.sh)
Script Components
Detection Script
The detection script runs on the device and outputs JSON with compliance settings:Discovery Rules
Define the expected values for each setting returned by the detection script:- Data type (Boolean, Integer, String, DateTime)
- Operator (Equals, NotEquals, GreaterThan, LessThan, etc.)
- Expected value
Use Cases
- Custom security controls - Check for specific registry keys, files, or configurations
- Third-party software - Verify antivirus, DLP, or EDR agent installation and version
- Hardware requirements - Check for specific hardware components or capabilities
- Configuration drift - Detect unauthorized changes to critical settings
- License compliance - Verify software licensing status
Graph API Details
Export/Import
Custom compliance scripts export to:Multi-Cloud Support
Compliance policies and scripts are supported across all four cloud environments:| Cloud | Graph Base URL | Authority Host |
|---|---|---|
| Commercial | https://graph.microsoft.com/beta | login.microsoftonline.com |
| GCC | https://graph.microsoft.com/beta | login.microsoftonline.com |
| GCC-High | https://graph.microsoft.us/beta | login.microsoftonline.us |
| DoD | https://dod-graph.microsoft.us/beta | login.microsoftonline.us |
Required Permissions
The app registration must have the following Microsoft Graph permission consented:- Read access to all compliance policies and scripts
- Create, update, and delete permissions for compliance policies
- Assignment management for compliance policies
- Read access to custom compliance script definitions
DeviceManagementConfiguration.Read.All can be used instead.
Best Practices
Policy Design
- Start with platform-specific baselines - Use Microsoft’s recommended compliance settings as a starting point
- Avoid overly restrictive policies - Balance security with user productivity
- Use grace periods - Give users time to remediate compliance issues before blocking access
- Test in pilot groups - Deploy to small groups before broad rollout
- Monitor compliance reports - Review compliance status regularly and adjust policies as needed
Custom Scripts
- Keep scripts simple - Complex scripts may timeout or fail intermittently
- Handle errors gracefully - Return valid JSON even when detection fails
- Test across OS versions - Ensure compatibility with all supported Windows/macOS versions
- Document script logic - Include comments explaining what each setting checks
- Version control - Track script changes using export/import and external version control
Assignment Strategy
- Use Azure AD dynamic groups - Automatically target devices by platform, OS version, or ownership
- Layer policies - Combine platform-specific and security-level policies using multiple assignments
- Exclude service accounts - Prevent compliance policies from blocking kiosk or shared devices
- Monitor assignment coverage - Ensure all devices are covered by at least one compliance policy
Caching
Compliance policy data is cached locally for 24 hours using an AES-encrypted LiteDB database: Cache Location:- Windows:
%LocalAppData%\Intune.Commander\cache.db - Linux:
~/.config/Intune.Commander/cache.db - macOS:
~/Library/Application Support/Intune.Commander/cache.db