Hi Mytoast Admin,
From my understanding, you are looking to automatically create and use ExtensionAttributes on devices based on user locations M365 portal during user creation during auto-enrollment.
The answer to this is Yes, you can achieve this using Graph SDK:
Below are the steps:
- Find all registered devices with the Get-MgDevice cmdlet.
- For each device, extract the identifier for the user’s account. This is stored in an odd manner in the device record (at least, Microsoft could make it much simpler to find and use the identifier).
- Use the Get-MgUser cmdlet to check the identifier against Entra ID and retrieve user details if a match is successful. The lookup fails if the user is no longer in Entra ID or their account belongs to another tenant (Entra ID can register devices for guest users).
- Run Update-MgDevice to populate the extension attributes when we have an account match.
If you find the answer above helpful, please Accept the answer to help anyone in the community who might have a similar question to quickly find the solution.