HuduM365Automation
HuduM365Automation copied to clipboard
EPM Device is matching users on Enrollment User instead of Primary User
I have noticed that the script is matching devices to users based on the user who enrolled the device, instead of who is the Primary User.
Given that the Primary user is what is usually used to track the device owner, I would suggest using this instead if possible.
My research tells me that https://graph.microsoft.com/v1.0/deviceManagement/managedDevices
annoyingly returns only the enrollment user, which I assume is why this is used instead of Primary user.
I believe you should be able to use https://graph.microsoft.com/v1.0/deviceManagement/managedDevices/{managedDevice-id}/users
(then get the .value.userPrincipalName
field from this result instead to get the Primary User, though I don't have the exact know-how of how to do this to create a pull request.
Thanks!