A service that simplifies device provisioning and setup for end users, enabling zero-touch deployment
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