Graph API: ManagedDevices not updating Primary User when changed from the Intune Portal

Michael DiGregorio 1 Reputation point
2024-05-08T15:42:14.6566667+00:00

I've noticed that if I change the primary user for a device in the Intune Portal, that change is not reflected when making a Get request to "https://graph.microsoft.com/v1.0/devicemanagement/manageddevices/<deviceID>"

Oddly, though, if I use the built in cmdlets for the Graph module (Get-MgDeviceManagementManagedDevice) and pass a filter for the device name rather than passing the manageddeviceid, that does show the correct primary user.

e.g. Get-MgDeviceManagemenManagedDevice -ManagedDeviceID <deviceID> = Old User

Get-MgDeviceManagemenManagedDevice -filter "devicename eq '<devicename>'" = Updated User

invoke-mggraphrequest -method get -uri "https://graph.microsoft.com/v1.0/devicemanagement/manageddevices/<deviceID>" = Old User

It doesn't seem like a PowerShell specific issue as I experience something similar in our iPaaS solution. I am wondering why filtering based on device name returns the correct value, why the updated primary user is not being reflected in the UserPrincipalName and UserDisplayName Graph properties when directly querying the uri with the manageddeviceid, and whether this is a known issue that is already being addressed.

I also found this related thread, but it doesn't seem like it went anywhere: https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/717

Windows for business Windows Server User experience PowerShell
Microsoft Security Intune Other
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Crystal-MSFT 53,981 Reputation points Microsoft External Staff
    2024-05-09T03:06:02.9366667+00:00

    @Michael DiGregorio, Thanks for posting in Q&A. Based on my checking, the API you request cannot get primary user. But you can get the Primary User via the following API.

    GET /beta/deviceManagement/managedDevices/{managedDeviceId}/users

    User's image

    Here is a link list the script to get device primary user for your reference.

    https://github.com/microsoftgraph/powershell-intune-samples/blob/master/ManagedDevices/Win10_PrimaryUser_Get.ps1

    Note: Non-Microsoft link, just for the reference.

    For command "Get-MgDeviceManagemenManagedDevice", based on my testing, I have the same result when using "ManagedDeviceID" to query, the user principal name is not updated.

    User's image For this command issue, please open case to get help on this.

    https://learn.microsoft.com/en-us/mem/get-support

    Hope the above information can give you some help.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

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