--- title: "Identify Non-Compliant or Unenrolled Devices Accessing Corporate Data" slug: "dex-wf-noncompliant-unenrolled-devices-access" updated: 2026-11-30T16:15:00Z published: 2026-11-30T16:15:00Z canonical: "documentation.sysaid.com/dex-wf-noncompliant-unenrolled-devices-access" --- > ## Documentation Index > Fetch the complete documentation index at: https://documentation.sysaid.com/llms.txt > Use this file to discover all available pages before exploring further. # Identify Non-Compliant or Unenrolled Devices Accessing Corporate Data Audit Entra ID sign-in logs against Intune enrollment and compliance state to surface unmanaged devices touching SharePoint, OneDrive, and other corporate resources. **Complexity:** Advanced. **Impact:** security + compliance + audit + intune + conditional-access. ## Why use this workflow Conditional Access and Intune compliance policies are only effective if every device touching corporate data is enrolled and evaluated. Gaps open up: personal phones that slipped past enrollment, contractor laptops, devices that fell out of compliance, or sign-ins where Entra ID could not capture a device ID at all. This workflow correlates two data sources, the Intune `managedDevices` inventory and the Entra ID `signIns` audit log, to produce a report of every user and device pair that accessed corporate data in the last 7 days **while being either non-compliant or not enrolled**. SharePoint Online and OneDrive access is flagged separately, because those workloads typically host the most sensitive data. **When to run it:** - Regularly as part of a device hygiene review - Before tightening a Conditional Access policy to require compliant devices (to understand the impact) - After a compliance baseline change, to find devices that fell out of compliance - During incident response when unmanaged access is suspected ## Expected outcomes - A CSV report of every non-compliant or unenrolled device that accessed corporate data in the last 7 days, grouped by user and device - A count of sign-ins per device and the resources accessed (SharePoint, Exchange, Teams, and others) - A separate flag column highlighting devices that accessed SharePoint Online or OneDrive - A list of enrolled but non-compliant devices from Intune for remediation - Evidence to justify (or scope) a Conditional Access policy requiring device compliance ## Risks and considerations ### Data volume and API throttling The `signIns` endpoint can return a large number of records per week in a mid-sized tenant. Paginate with `@odata.nextLink` and cap your result set (for example, 10,000 rows) to avoid throttling (HTTP 429). Add `$top=500` to reduce round trips. ### Device ID correlation is imperfect Not every sign-in has a `deviceDetail.deviceId`. Sign-ins from private browser sessions, legacy authentication, or some mobile apps have a blank device ID. Treat these as *Unknown (No Device ID)* and do not assume they are safe. ### Do not enumerate SharePoint sites by display name The Graph `/sites` endpoint does not support tenant-wide enumeration through `$filter=contains(displayName,...)`. Use the resource names that appear in the sign-in log (`Office 365 SharePoint Online`, `OneDrive`) as your sensitivity signal, or cross-reference against a curated list of sensitive site IDs that you maintain separately. ### Licensing Reading sign-in logs through Graph requires Microsoft Entra ID P1 or P2. Without it, the `/auditLogs/signIns` endpoint returns 403. ### Privacy and retention Sign-in logs contain IP addresses, locations, and user identities. Handle the output CSV as confidential and follow your data retention policy before archiving. ### Review before acting Some unmanaged sign-ins are legitimate: service accounts, break-glass accounts, or approved BYOD covered by App Protection Policies rather than MDM. Review the report before blocking anything. ## Required permissions | Permission | Why it's needed | | --- | --- | | DeviceManagementManagedDevices.Read.All | Read the Intune managed devices inventory and their compliance state | | AuditLog.Read.All | Read Entra ID sign-in logs for the correlation window | | Directory.Read.All | Resolve user principal names and device directory objects referenced in sign-in logs | | Sites.Read.All | Optionally resolve SharePoint site metadata when correlating against a curated sensitive-site list | ## Ask Dex Paste the prompt into a Dex conversation. ### Prompt for IT admins ``` List all devices that accessed corporate data in the last {days} days but are not compliant or not enrolled in Intune. Flag any that touched SharePoint or OneDrive and export a CSV report. ``` ## Manual steps (admin center) This is a multi-portal workflow. No single view provides this correlation, so you pull each dataset and reconcile them in a spreadsheet. ### Step 1: Export Intune device compliance 1. Sign in to the [Microsoft Intune admin center](https://intune.microsoft.com). 2. Go to **Devices** > **All devices**. 3. Click **Columns** and make sure *Compliance*, *OS*, *Primary user UPN*, *Azure AD Device ID*, and *Model* are visible. 4. Click **Export** to download the device list as CSV. This is your enrollment and compliance baseline. ### Step 2: Review non-compliant devices 1. In Intune, go to **Devices** > **Monitor** > **Noncompliant devices**. 2. Note the count and export the list. These devices are enrolled but failing policy, so they are remediation candidates. ### Step 3: Pull sign-in logs from Entra ID 1. Open the [Microsoft Entra admin center](https://entra.microsoft.com). 2. Go to **Identity** > **Monitoring & health** > **Sign-in logs**. 3. Set the date filter to **Last 7 days**. 4. Add filters: *Status = Success*, and optionally *Application contains SharePoint* to scope to SharePoint access. 5. Click **Download** and choose *JSON* or *CSV*. Include the *Device* and *Device ID* columns. ### Step 4: Correlate in Excel or Power BI 1. Open both exports. In the sign-in log, add a lookup column: `VLOOKUP(DeviceId, IntuneExport!AzureADDeviceId, ComplianceState)`. 2. Filter rows where the lookup returns *#N/A* (not enrolled) or *noncompliant*. 3. Add a flag column: `=IF(ISNUMBER(SEARCH("SharePoint",ResourceDisplayName)),"SharePoint","")` 4. Sort by the SharePoint flag, then by sign-in count per user and device. The API and script paths below do the same work without manual correlation. ## Microsoft Graph API Three Graph calls, joined in memory. All paths are relative to `https://graph.microsoft.com`. ### 1. List managed devices with compliance state ``` GET /v1.0/deviceManagement/managedDevices?$select=id,deviceName,userPrincipalName,complianceState,operatingSystem,model,azureADDeviceId&$top=200 ``` Paginate with `@odata.nextLink`. Build a dictionary keyed on `azureADDeviceId` (lowercased) for fast lookup. Note: `isRooted` is not selectable on the v1.0 or beta `managedDevice` type. Do not add it to `$select`, or the request returns HTTP 400. ### 2. Query successful sign-ins for the last 7 days ``` GET /v1.0/auditLogs/signIns?$filter=createdDateTime ge 2025-01-15T00:00:00Z and status/errorCode eq 0&$select=createdDateTime,userPrincipalName,deviceDetail,resourceDisplayName,appDisplayName&$top=500 ``` Example response fragment: ``` {  "createdDateTime": "2025-01-20T14:32:11Z",  "userPrincipalName": "alice@contoso.com",  "resourceDisplayName": "Office 365 SharePoint Online",  "appDisplayName": "OneDrive",  "deviceDetail": {    "deviceId": "b5976a7e-2fbd-47f8-8e28-86af883c720f",    "displayName": "LAPTOP-42",    "operatingSystem": "Windows 10",    "isCompliant": false,    "isManaged": false  } } ``` ### 3. Join and filter For each sign-in, look up `deviceDetail.deviceId` in the managed devices dictionary: - **Match and compliant:** skip (healthy). - **Match and noncompliant:** flag as *Enrolled, Non-Compliant*. - **No match:** flag as *Not Enrolled*. - **Empty deviceId:** flag as *Unknown (No Device ID)*. Then flag any row where `resourceDisplayName` or `appDisplayName` contains `SharePoint` or `OneDrive` as sensitive-data access. ### Throttling If you get HTTP 429, honor the `Retry-After` header. Cap your result set at roughly 10,000 sign-ins and narrow the `$filter` (for example, by `appDisplayName`) if you exceed that. ## PowerShell The approach does the full correlation in one run: it pulls Intune devices, pulls 7 days of sign-ins, joins them, and exports a CSV with SharePoint flagging. ### Prerequisites - PowerShell 7 or later - `Microsoft.Graph` SDK installed: `Install-Module Microsoft.Graph -Scope CurrentUser` - Microsoft Entra ID P1 or P2 license (required for sign-in log access) - Consented scopes: `DeviceManagementManagedDevices.Read.All`, `AuditLog.Read.All`, `Directory.Read.All` ### Approach 1. Connect to Graph with the required scopes (delegated or app-only). 2. Page through `/deviceManagement/managedDevices` into a hashtable keyed on `azureADDeviceId`. 3. Page through `/auditLogs/signIns`, filtered to successful sign-ins in the time window. 4. For each sign-in, look up the device and classify it as Enrolled/Compliant, Enrolled/Non-Compliant, Not Enrolled, or Unknown. 5. Flag sign-ins to SharePoint Online or OneDrive as sensitive access. 6. Group by user and device, compute counts, and write a CSV sorted with the highest-risk entries first. ### Expected output A CSV similar to: ``` User,DeviceName,DeviceId,OS,EnrollmentStatus,ComplianceState,TotalAccesses,SharePointAccesses,RiskFlag alice@contoso.com,LAPTOP-42,b5976a7e-...,Windows 10,Not Enrolled,N/A,27,22,SharePoint Access bob@contoso.com,SBI-IPAD-...,iPad Pro 13,iOS,Enrolled,noncompliant,14,8,SharePoint Access ```