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.
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 -NoTypeInformationGET https://graph.microsoft.com/v1.0/deviceManagement/managedDevices?$filter=complianceState eq 'noncompliant'&$select=deviceName,userPrincipalName,operatingSystem,osVersion,lastSyncDateTime
# Permission: DeviceManagementManagedDevices.Read.AllPrerequisites
- 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
| Author | Role |
|---|---|
| Priyanshu Upadhyay | Solution Architect, Microsoft 365 and Azure |
InnovaticT