Identify Stale Intune Devices and Trigger a Remote Sync

Prev Next

Find managed devices that haven't checked into Intune recently and force a policy sync to bring them current.

Complexity: Intermediate. Impact: device-management + compliance + fleet-hygiene + intune.

Why use this workflow

Intune-managed devices periodically check in with the service to pull down configuration profiles, compliance policies, and app assignments. When a device stops checking in, it drifts out of compliance, misses security policy updates, and may look healthy in reports while being unmanaged in practice.

This workflow identifies devices whose lastSyncDateTime is older than a cutoff you choose (for example, since last Friday, or more than 7 days ago) and issues a remote syncDevice action to each one. It is a common hygiene task and a useful first response when users report that a new policy, app, or certificate hasn't arrived on their machine.

When to run it

  • Regularly, as part of device fleet hygiene
  • After you push a high-priority configuration profile or compliance policy
  • When you investigate a rollout that appears stuck on a subset of devices
  • Before you generate compliance reports for auditors

Expected outcomes

  • A list of all Intune-managed devices whose last check-in is older than your chosen cutoff, including device name, assigned user, OS, and last sync timestamp
  • A remote sync action queued against every stale device
  • A run log you can attach to a ticket or change record showing which devices were targeted and whether the service accepted the sync action
  • Reduced policy drift and faster convergence on your current Intune baseline

Risks and considerations

  • Sync is a request, not a guarantee. The syncDevice action only succeeds if the device is online and can reach Intune. Offline, retired, or decommissioned devices stay stale no matter how many times you trigger a sync.
  • Abandoned devices need retirement, not sync. If a device has been offline for a long time, investigate whether it was lost, reimaged, or left the fleet. Consider the retire or delete action instead.
  • Watch for throttling. Graph throttles bulk device actions. For large numbers of stale devices, add delays between calls or batch them.
  • Do not rely on lastSyncDateTime alone for compliance decisions. A device that synced recently can still be non-compliant. Use complianceState for that signal.
  • Time zones matter. lastSyncDateTime is UTC. Compute your cutoff in UTC as well.
  • Use a documented service account for scheduled runs so that the actions are attributable.

Required permissions

PermissionWhy it's needed
DeviceManagementManagedDevices.Read.AllEnumerate managed devices and read lastSyncDateTime to identify stale devices
DeviceManagementManagedDevices.PrivilegedOperations.AllInvoke the syncDevice remote action against each stale device
DeviceManagementManagedDevices.ReadWrite.AllRequired in some tenants alongside PrivilegedOperations for device action endpoints

Ask Dex

Paste the prompt into a Dex conversation.

Prompt for IT admins

Identify all Intune-managed devices that haven't checked in since {cutoff_date} (e.g., last Friday) and trigger a remote sync on each one. Give me a summary of how many devices were targeted, which succeeded, and flag any that have been offline for more than 30 days as candidates for retirement.

Manual steps (admin center)

Use this approach for small fleets or one-off investigations. For larger numbers of devices, use the API or PowerShell approach.

Step 1: Open the devices list

Microsoft Intune admin center > Devices > All devices

Step 2: Filter to stale devices

  1. Select Filter above the device list.
  2. Add a filter on Last check-in.
  3. Set the operator to Before and choose your cutoff date.
  4. Optionally, add OS or Compliance state filters to narrow the list.
  5. Select Apply.

Select Export to download the filtered device list as CSV. Keep it as evidence of what you targeted.

Step 4: Trigger sync

  1. Select the checkbox next to each stale device (or use Select all on the current page).
  2. Select Sync in the command bar at the top of the list.
  3. Confirm the action in the dialog.

The portal only acts on the currently visible page. For multi-page results, paginate through them or switch to the scripted approach.

Step 5: Verify

After a short wait, refresh the device list and check that Last check-in has updated for the devices that were online. Any device whose timestamp did not change is likely offline or unreachable. Flag those for follow-up.

Microsoft Graph API

Two endpoints do the work: list managed devices, then invoke the sync action on each stale one.

1. List managed devices

GET https://graph.microsoft.com/v1.0/deviceManagement/managedDevices?$select=id,deviceName,userPrincipalName,lastSyncDateTime,operatingSystem,complianceState
Authorization: Bearer {access_token}

Follow @odata.nextLink until you have paged through the full fleet. Sample response item:

{
  "id": "a1b2c3d4-...",
  "deviceName": "LAPTOP-ABC123",
  "userPrincipalName": "jane@contoso.com",
  "lastSyncDateTime": "2026-02-10T14:22:18Z",
  "operatingSystem": "Windows",
  "complianceState": "compliant"
}

2. Filter locally

Filter on lastSyncDateTime client-side. Keep any device where lastSyncDateTime is null or earlier than your cutoff (in UTC).

3. Trigger sync on each stale device

POST https://graph.microsoft.com/v1.0/deviceManagement/managedDevices/{deviceId}/syncDevice
Authorization: Bearer {access_token}
Content-Length: 0

A successful call returns HTTP 204 No Content. The action is queued, and the device picks it up when it next checks in.

Common errors

  • 403 Forbidden: missing DeviceManagementManagedDevices.PrivilegedOperations.All.
  • 404 Not Found: the device was deleted between the list call and the action. Skip it.
  • 429 Too Many Requests: honor the Retry-After header and back off.

PowerShell

Use the Microsoft Graph PowerShell SDK to enumerate devices, filter for stale ones, and invoke syncDevice on each.

Prerequisites

  • PowerShell 7 or later (Windows PowerShell 5.1 also works)
  • Install-Module Microsoft.Graph -Scope CurrentUser
  • An account or app registration with the permissions listed above, consented at the tenant level

Approach

  1. Connect to Graph with the required scopes:
    Connect-MgGraph -Scopes "DeviceManagementManagedDevices.Read.All","DeviceManagementManagedDevices.PrivilegedOperations.All"
  2. Page through /deviceManagement/managedDevices, selecting only the columns you need.
  3. Filter for devices whose LastSyncDateTime is older than your cutoff (computed in UTC).
  4. Run in report-only mode first: write the target list to a CSV and review it before you send any sync action.
  5. Issue Invoke-MgSyncDeviceManagementManagedDevice against each stale device, with a short delay between calls to avoid throttling.
  6. Capture successes and failures and write a summary CSV.