Report · 2 tools

Non-compliant Intune devices with the failing policy

Summary

Lists every non-compliant managed device with its primary user, OS and last check-in, and the compliance policies it fails, so the service desk can chase the right people.

Implementation

Choose your tool. Your choice is remembered on other samples.

Microsoft Graph PowerShell
Connect-MgGraph -Scopes DeviceManagementManagedDevices.Read.All, DeviceManagementConfiguration.Read.All -NoWelcome
Get-MgDeviceManagementManagedDevice -All -Filter "complianceState eq 'noncompliant'" |
  ForEach-Object {
    $failing = Get-MgDeviceManagementManagedDeviceCompliancePolicyState -ManagedDeviceId $_.Id |
      Where-Object State -eq "nonCompliant" | Select-Object -ExpandProperty DisplayName
    [pscustomobject]@{ Device = $_.DeviceName; User = $_.UserPrincipalName; OS = "$($_.OperatingSystem) $($_.OsVersion)"
      LastSync = $_.LastSyncDateTime; FailingPolicies = ($failing -join ";") }
  } | Export-Csv .\noncompliant-devices.csv -NoTypeInformation

Prerequisites

  • Graph scopes DeviceManagementManagedDevices.Read.All and DeviceManagementConfiguration.Read.All
  • Intune Administrator or a read-only Intune role

Output

CSV of non-compliant devices and failing policies.

Related answers

Contributors

AuthorRole
Priyanshu UpadhyaySolution Architect, Microsoft 365 and Azure
Disclaimer. These samples are provided as is, without warranty of any kind. Read and test every script in a non-production tenant before you run it, and run reports before any command that changes or deletes data.