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

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,821 questions
Microsoft Intune
Microsoft Intune
A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.
4,456 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,136 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Crystal-MSFT 44,156 Reputation points Microsoft Vendor
    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.