Reading Intune Device Compliance States with Read-Only Microsoft Graph PowerShell
Which Intune devices are noncompliant, in error or unknown? List complianceState read-only with Get-MgDeviceManagementManagedDevice and read each beside its last sync.

Advertising disclosure: this article includes partner links. KBY may earn a commission if you sign up or buy through one, at no extra cost to you. How we make money.
Before you begin
- A Microsoft Intune tenant you are allowed to inspect, ideally a training tenant.
- The Microsoft Graph PowerShell SDK with the Microsoft.Graph.DeviceManagement module.
- A work or school account with the DeviceManagementManagedDevices.Read.All delegated permission, and no wider one.
Underlined words are defined in the KBY Lexicon. Tap or click one to see what it means.
To see how Microsoft Intune currently rates your devices, sign in to Microsoft Graph PowerShell with the read-only DeviceManagementManagedDevices.Read.All permission and run Get-MgDeviceManagementManagedDevice -All. Each device it returns carries a complianceState property, which Microsoft documents as one of unknown, compliant, noncompliant, conflict, error, inGracePeriod or configManager. Grouping the devices by that property gives you a count for each state without changing anything in the tenant.
The count is easy to misread. Noncompliant is only one of several answers that are not a clean pass, and every answer is a snapshot taken at the device’s last check-in. A report that says “12 noncompliant” without the date, the permission and the other states is half a finding. The full picture takes a few more properties and the same read-only habits as collecting diagnostics from a Windows device in Intune.
#By the end you can
- Explain where a device’s compliance state comes from and when it is refreshed.
- Name the documented
complianceStatevalues and say what each one tells you. - Connect with one read-only permission and check what the session was granted.
- List every managed device, group them by state and show the noncompliant ones with their last sync time.
- Report the counts with their date, and hand any action to the owner of the device.
#Before you begin
- A Microsoft Intune tenant you are allowed to inspect, ideally a training tenant with a few enrolled test devices.
- The Microsoft Graph PowerShell SDK, which provides
Connect-MgGraph, and itsMicrosoft.Graph.DeviceManagementmodule, which providesGet-MgDeviceManagementManagedDevice. - A work or school account that can use the
DeviceManagementManagedDevices.Read.Alldelegated permission. Microsoft lists it as the least privileged permission for listing managed devices, and the ReadWrite permission above it is not needed.
Microsoft notes that the Graph API for Intune requires an active Intune licence for the tenant. Check the licence first if the call is refused.
#How Intune records whether a device is compliant
Intune keeps one managed device record for each enrolled device. Compliance policies are assigned to users or devices, and each policy holds settings such as a password rule or an encryption requirement. Intune evaluates the device against every policy that applies and stores the result as a single compliance state on the device record. That record is what Graph returns, so the property describes the device as a whole and not any one policy.
Microsoft’s compliance monitoring page adds a point that matters for everything below. Compliance state is evaluated continuously, but the reports in Intune update when the device checks in. The state you read can therefore lag behind the device. The record also carries lastSyncDateTime, which Microsoft describes as the date and time the device last completed a successful sync with Intune, and that is the property that tells you how old the answer is.
The six states are worth learning one at a time, because they lead to different questions. The Graph pages describe the possible values, and the monitoring page explains what the admin centre means by them.
- compliant: the device applied the compliance settings it was evaluated against.
- noncompliant: the device failed to meet at least one compliance setting, or the user did not comply.
- inGracePeriod: the device is not yet compliant with every setting, but the admin has set a grace period. The record carries
complianceGracePeriodExpirationDateTimefor when it ends. - error: a setting could not be evaluated. Microsoft says a device’s existing state stays unchanged for up to seven days while an Error setting resolves, after which it becomes Not compliant, or In grace period if a grace period is set.
- unknown: the documented default. The monitoring page describes a Not evaluated state for newly enrolled devices and for devices that have not checked in since a policy changed, but the pages do not say how that maps to the API value.
- conflict and configManager: listed as possible values without an explanation in the pages used here, so read them as a prompt to check the documentation before you act.
Two defaults can change the numbers without any device changing. The tenant-wide setting Mark devices with no compliance policy assigned as is documented as marking such devices compliant by default, so a compliant device may have no policy at all. The same page says compliance reports show the last user on the device, so a shared device can appear under someone who no longer uses it.
The diagram shows the reading order this guide follows. Every state other than compliant leads to the same next question, which is how old the answer is.

#A worked example: four devices, four different answers
Suppose a small training tenant has four enrolled Windows laptops. The output below is invented to show how to read the result, and it is not taken from a real tenant. The command groups the devices by ComplianceState, then lists the ones that are not compliant with their last sync time.
1Count Name
2----- ----
3 2 compliant
4 1 noncompliant
5 1 inGracePeriod
6
7DeviceName LastSyncDateTime ComplianceGracePeriodExpirationDateTime
8---------- ---------------- ---------------------------------------
9LAB-WIN-03 2026-11-02 08:14
10LAB-WIN-04 2026-12-04 17:40 2026-12-09 17:40Read the table before the headline. LAB-WIN-04 is inside its grace period, so it is failing something but has until 9 December to fix it, and it synced yesterday, so the answer is fresh. LAB-WIN-03 is the one to question. It is marked noncompliant, but its last sync was over a month ago, which means the state may describe a laptop that has been in a drawer.
The count of one noncompliant device is therefore not a security finding yet. It could be a real setting failure, a device that has gone quiet, or both. The list cannot say which, and it does not need to. It tells you who to ask and what to ask them, and the answer may well be that the laptop was retired and never removed from Intune.
#Your turn: list the compliance states in a training tenant
Objective. Produce a count of devices for each compliance state and a short table of the noncompliant ones with their last sync time, plus a note of what the list cannot tell you. Safe setup. Every command only reads. Do not run any cmdlet whose name begins New-, Update-, Remove- or Invoke- against managed devices, because those can wipe, retire or change a device.
- Connect with one read-only scope:
Connect-MgGraph -Scopes "DeviceManagementManagedDevices.Read.All". Sign in when prompted and consent only if the prompt names that permission. - Check what you were granted with
Get-MgContext. Look atScopesandAuthType. You expect the scope you asked for and a delegated session. - Read the devices into a variable:
$devices = Get-MgDeviceManagementManagedDevice -All -Property Id,DeviceName,OperatingSystem,OsVersion,ComplianceState,LastSyncDateTime,EnrolledDateTime,ComplianceGracePeriodExpirationDateTime,UserPrincipalName. The-Allswitch follows every page of results. - Count the devices with
$devices.Count. - Group them by state with
$devices | Group-Object ComplianceState | Select-Object Count, Name. - Show the noncompliant devices, stalest first:
$devices | Where-Object ComplianceState -eq 'noncompliant' | Sort-Object LastSyncDateTime | Format-Table DeviceName, OperatingSystem, LastSyncDateTime. - Show the devices with no clear verdict:
$devices | Where-Object ComplianceState -in 'error','unknown' | Format-Table DeviceName, ComplianceState, EnrolledDateTime, LastSyncDateTime. - End the session with
Disconnect-MgGraph.
Following along? Tap a step’s number to tick it off.
Expected evidence. Step 2 shows your requested scope and a delegated auth type. Step 4 gives a whole number, possibly zero. Step 5 gives one row for each state present, and the counts add up to the number from step 4. Steps 6 and 7 give one row for each matching device, or no rows at all if none match.
Pass condition. You can write: “On [date], with DeviceManagementManagedDevices.Read.All, the tenant had [n] managed devices, [a] noncompliant, [b] in error or unknown, and the stalest noncompliant device last synced on [date].” You can also name one thing the list does not tell you.
Stop condition. Stop if the sign-in asks for a scope with ReadWrite in its name, or asks you to approve something for the whole organisation that you did not expect. Cancel and ask the owner of the tenant. Cleanup. Run Disconnect-MgGraph. Nothing was changed, so nothing needs rolling back.
#How to check that the counts are honest
Run Get-MgContext first. A session with only the read scope you asked for and an AuthType of Delegated is the session you meant to have. Next, check that the state counts add up to the device total. If they do not, a page of results was missed or a property came back empty for some devices.
Then compare one device by hand. Open it in the Microsoft Intune admin centre and read its compliance status and last check-in, and check that they match what PowerShell returned. A small difference in time is normal, because the reports refresh at check-in. A different state is worth a second look at which property you read.
Finally, run the group count twice, a few minutes apart. The same numbers suggest a stable reading. A change is not an error, because devices check in all the time, but it does mean the count belongs to a moment and should be reported with its date.

#What goes wrong when you read compliance states
- Equating noncompliant with at risk. The state records that a setting failed, not what the failure exposes. Read the policy and the device before drawing a conclusion.
- Ignoring the other states. A report that counts only noncompliant hides the devices in error or unknown, which have no verdict at all.
- Reading an old state as current. A device that has not synced for weeks keeps its last recorded state. Always show
LastSyncDateTimebeside the state. - Trusting a compliant count. If the tenant marks devices with no policy as compliant, the number includes devices nobody evaluated.
- Comparing the property case by case. If
Where-Objectreturns nothing, print one value with$devices[0].ComplianceStateand read how the SDK spells it before you conclude that no device matches. - Using a wider permission. The ReadWrite permission can also change devices. Keep the read scope, and ask for access rather than a bigger scope if the call is refused.
If a device looks wrong rather than merely out of date, the next step is a diagnosis of that one device, such as tracing an endpoint problem with Microsoft Intune. If the issue is that a policy reached the wrong devices, narrowing a policy with an assignment filter explains how targeting works.
#Taking compliance reporting into production
Run this in production only when you have a reason and read access already. Use a named account, record the date, the permission and the counts, and keep the output where only people entitled to see device and user names can read it. The listing includes device names and user principal names, so a screenshot in a chat channel is a disclosure.
Acting on a device is a separate decision. Retiring, wiping or deleting a managed device changes the tenant, can remove a user’s work, and may be impossible to undo, so it needs the device owner, a change record and a backup of anything the device holds. None of that is covered here. For devices that have gone quiet, the script for Intune devices that have not synced in N days shows one way to list them.
Escalate when the numbers do not match the admin centre, when a large share of devices sits in error or unknown, or when a noncompliant device belongs to a privileged user. In each case the finding is the evidence you gathered, and the next safe decision belongs to the owner of Intune policy in your organisation.
#What to remember about compliance states
- The compliance state is one value for the whole device, recorded at its last check-in.
- Noncompliant is one of several answers; error and unknown mean no verdict, and a compliant device may have no policy at all.
- Use
DeviceManagementManagedDevices.Read.Allonly, with-Alland-Property, and showLastSyncDateTimebeside every state. - A count is a snapshot, so report it with the date and the permission.
- Leave retiring, wiping and deleting to the owner of the device.
Evidence trail
Sources and verification
Primary documentation and external technical references used in this article.
About this page
Credited to
Dates
Published
Corrections
No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.
Found this useful? Follow KBY for more like it.
Recommended reading
More from KBY that goes with this article.

- Microsoft Intune error
0x801C03EA: Autopilot fails at Registering your device for mobile management
2 min read
Related articles
Endpoint and Device Management
Narrowing an Intune Policy to the Right Devices with an Assignment Filter
Need an Intune policy on only some devices in a group? Build an assignment filter, preview matches, pick Include or Exclude and read the Filter evaluation report.
ReadEndpoint and Device Management
Collecting Diagnostics from a Windows Device in Intune and Reading What Comes Back
How do you pull logs from a Windows device in Intune? Run Collect diagnostics, follow Device diagnostics, then read dsregcmd, MDM and IME logs in the zip.
ReadSecurity & Operations
Design Defender for Endpoint Device Groups: Tag-Based Matching, Ranking and Safe Changes
Use tags and ranked device groups in Defender for Endpoint so each team sees only its devices, and change groups without losing notification rules.
ReadPlatforms and devices
Windows 11 Five-Digit Build Revisions: Check Intune Limits That End in .9999
Microsoft's MC1575953 says Windows 11 revisions now reach five digits, so an Intune maximum OS version ending .9999 can mark updated devices noncompliant.
ReadDiscover more
Graduate Learning
- TutorialWorking Out Why an Intune App Install Failed on One Windows Device
- TutorialNarrowing an Intune Policy to the Right Devices with an Assignment Filter
- TutorialCollecting Diagnostics from a Windows Device in Intune and Reading What Comes Back
- TutorialTracing an Endpoint and Device Management Problem with Microsoft Intune
Ops Playbook
- PlaybookInstall containerd on Autopilot Laptops Without Rebooting Mid-Provisioning
- PlaybookReplace Remote-Control Sessions With Intune Device Query for First-Line Windows Triage
- PlaybookFind the Windows Apps That Crash Most With Intune’s Application Reliability Report
- PlaybookDeploy Teams Rooms on Windows With Autopilot Self-Deploying Mode and Autologin
Lexicon Definitions
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.
Build practical engineering skills.
Receive new lessons, learning paths, practical exercises and early-career guidance.
Comments
Add a thoughtful note on Reading Intune Device Compliance States with Read-Only Microsoft Graph PowerShell. Comments are checked for spam and held for moderation before appearing.