Share via

Autopilot - Looking to have a device added to Entra Group after Autopilot completes

M T 55 Reputation points
2026-02-13T11:13:38.1766667+00:00

Hello everyone, I’m looking for a way to populate a dynamic group with devices that have completed Autopilot. The challenge we’re facing is that we want applications and policies to deploy only after a device has finished Autopilot and a user has logged in. We do not want to assign all apps and policies directly to users.

I’ve been experimenting with a script (deploying through Win32App during autopilot) that uses the device ID during Autopilot to update a device extension attribute, but it doesn’t seem to work when using Connect-MgGraph -Identity.

Currently we have a dynamic group with devices that are tagged. But would like to have another dynamic group populate once the device completed autopilot.

Microsoft Security | Windows Autopilot
{count} votes

1 answer

Sort by: Most helpful
  1. Marcin Policht 82,360 Reputation points MVP Volunteer Moderator
    2026-02-13T14:30:55.15+00:00

    AFAIK, there isn’t a native Entra ID or Intune attribute that flips to “Autopilot completed” in a way dynamic device groups can evaluate, so you'd need t okey off something that only exists after ESP completion and first user sign-in. The two signals you might consider are device ownership becoming “Company” with a primary user assigned, or a custom attribute written after enrollment using a mechanism that runs in the user context after ESP finishes. Unfortunately, trying to update extension attributes during ESP with Connect-MgGraph -Identity will likely fail because the device context does not have Graph permissions and the managed identity flow is not available in that stage of Autopilot.

    One approach without scripting Graph is to leverage the primary user assignment because that only exists once a user has logged in successfully. You can create a dynamic device group that evaluates the existence of a registered or primary user. For example, you can try using a rule similar to the following, which only captures devices after a user association exists:

    (device.deviceOwnership -eq "Company") and (device.registeredOwners -any (_ -ne null))
    

    Depending on your tenant schema you may instead rely on:

    (device.devicePhysicalIDs -any (_ -contains "[ZTDId]")) and (device.managementType -eq "MDM") and (device.enrollmentProfileName -ne null)
    

    combined with requiring a primary user through an Intune filter or assignment filter, since primary user assignment happens post-login. Another approach might be deploying a remediation script or scheduled task assigned to “All Devices” but configured to run in user context after enrollment, which writes a local registry value. You then use a Proactive Remediation or custom compliance policy that marks the device compliant only after that value exists, and you target apps and policies to a dynamic device group filtered on compliance state:

    (device.isCompliant -eq true) and (device.devicePhysicalIDs -any (_ -contains "[ZTDId]"))
    

    If you want to stamp an Entra extension attribute, you might try calling Graph using an app registration with certificate or secret and grant Device.ReadWrite.All, then run the script as a user-context PowerShell script assigned after ESP rather than as a Win32 app during Autopilot. Example structure:

    Connect-MgGraph -TenantId "<tenant>" -ClientId "<appId>" -CertificateThumbprint "<thumbprint>"
    Update-MgDevice -DeviceId $env:AZUREADDEVICEID -ExtensionAttributes @{extensionAttribute1="AutopilotComplete"}
    

    Your dynamic device group would then simply evaluate:

    (device.extensionAttribute1 -eq "AutopilotComplete")
    

    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.