Compliance Notcompliant Devices
Query
IntuneDeviceComplianceOrg
| where todatetime(LastContact) > ago(30d)
| where ComplianceState == "Not compliant"
| summarize arg_max(TimeGenerated, *) by DeviceName
| project ComplianceState, DeviceName, LastContactExplanation
This query is checking the compliance status of devices in an organization using Intune Device Compliance. It filters out devices that have not been in contact for more than 30 days and those that are not compliant. It then returns the most recent record for each device based on the time the data was generated. The final output of the query will show the compliance state, device name, and the last contact time.