Unmanaged / non-compliant devices
Devices that are not managed or not marked compliant sit outside the controls your organisation relies on to protect data, such as Conditional Access rules that require a compliant device. A read-only Microsoft Graph PowerShell script lists them from the Microsoft Entra device registry so you can enrol, fix or retire each one.
Why it matters
Device compliance is how Microsoft Intune reports whether a device meets the rules you set (Get started with device compliance). Conditional Access can then require a compliant device before granting access (Require compliant devices), so devices that are unmanaged or non-compliant either get blocked or, where no such policy exists, reach company data with no checks at all. Both outcomes are worth knowing about.
Find it yourself
This script is read-only: it only calls Get-MgDevice and writes nothing back to your tenant. It needs the delegated Device.Read.All permission. The IsManaged and IsCompliant properties are documented on the device resource type.
Connect-MgGraph -Scopes "Device.Read.All" -NoWelcome
$devices = Get-MgDevice -All -Property Id,DisplayName,OperatingSystem,OperatingSystemVersion,TrustType,IsManaged,IsCompliant,ApproximateLastSignInDateTime,AccountEnabled
$devices |
Where-Object { $_.IsManaged -ne $true -or $_.IsCompliant -ne $true } |
Select-Object DisplayName, OperatingSystem, TrustType, IsManaged, IsCompliant, ApproximateLastSignInDateTime, AccountEnabled |
Sort-Object ApproximateLastSignInDateTime |
Format-Table -AutoSize
Disconnect-MgGraphRead the result
A row appears when a device is not managed, not compliant, or has no value for either property. Separate the cases: IsManaged empty or false means no mobile device management is reporting on it; IsManaged true with IsCompliant false means it is enrolled but failing a policy. TrustType shows how it joined (for example registered or joined), and an old ApproximateLastSignInDateTime usually points to a stale record rather than a live risk.
What to do next
Work through the list in three groups. Devices that are in use and unmanaged should be enrolled. Enrolled but non-compliant devices should be fixed against the failing compliance setting in Intune. Stale or retired devices should be disabled or removed through your normal process. Also check how Intune treats devices that have no compliance policy assigned, since that tenant-wide setting decides whether they count as compliant (documentation). Re-run the script to confirm the list shrinks.
See it continuously
ConfigCobra's Inventory & Insights includes a built-in risk view for unmanaged / non-compliant devices alongside the other Microsoft 365 objects it inventories. Findings link to the inventory objects they concern and you can export the list as CSV. Inventory is available on Microsoft 365, Azure, Google Cloud and AWS, with a per-cloud and an "All clouds" view. Start with the 14-day free trial.
Go further
- Inventory & InsightsEvery user, app, device and resource in one inventory, with built-in risk views
- Identity & Access GovernanceFind inactive users, guests, admins and risky apps
- Microsoft 365CIS v7.0.0 · 160 controls · read-only Microsoft Graph
- Users inactive 90 daysMicrosoft 365 insight
- Users who never signed inMicrosoft 365 insight
- Users with no MFA registeredMicrosoft 365 insight
- External mail forwardingMicrosoft 365 insight
See it for your whole tenant, continuously
Inventory & Insights lists these risks with built-in views and CSV export, read-only.