Query Details
// Number of Company owned Devices that are Compliant or Not Compliant summarized by OS Platform
let notcompliant =
IntuneDeviceComplianceOrg
| where ComplianceState == "Not compliant"
| where OwnerType == "Company"
| where OSDescription != ""
| summarize arg_max(TimeGenerated, *) by DeviceName
| project ComplianceState, DeviceName, LastContact, OSDescription, OS
| summarize count(DeviceName) by OSDescription;
let compliant =
IntuneDeviceComplianceOrg
| where ComplianceState == "Compliant"
| where OwnerType == "Company"
| where OSDescription != ""
| summarize arg_max(TimeGenerated, *) by DeviceName
| project ComplianceState, DeviceName, LastContact, OSDescription, OS
| summarize count(DeviceName) by OSDescription;
notcompliant
| join kind=inner compliant on OSDescription
| project-rename
["Compliant"]=count_DeviceName1,
["Not Compliant"]=count_DeviceName,
["Platform"]=OSDescription
| project ["Platform"], ["Compliant"], ["Not Compliant"]
| sort by Compliant desc This query is counting the number of company-owned devices that are either compliant or not compliant with certain standards, and then grouping these counts by the operating system (OS) of the devices.
First, it identifies all the non-compliant company-owned devices, excludes those without an OS description, and then counts them by their OS description.
Then, it does the same for compliant devices.
Finally, it combines the counts of compliant and non-compliant devices for each OS into a single table, and sorts this table in descending order by the number of compliant devices.

Ugur Koc
Released: December 29, 2022
Tables
Keywords
Operators