Share via

Changing primary user of a device in Intune using Microsoft Graph Powershell

Anonymous
2024-01-20T15:12:13+00:00

Hello All,

I ran into issues where our Technicians who reimage and deploy laptop/workstations to our users gets assigned as Primary user on the device. Right now, We have about less than 1000 devices that doesn't have the proper Primary user in Intune. We are currently fixing this via manual effort by doing several click but I wanted to automate our process to be more efficient. So installed Microsoft Graph Powershell and ran the script below but I am getting an error message.

I am not sure what I am doing wrong as the script provided on Microsoft website doesn't have any examples or syntax.

Script:

Connect-mgGraph

Update-MgDeviceManagementManagedDevice -manageddeviceid $deviceid -Users $userid

The value I have for the $deviceid is the Intune deviceid of the device while the value on the $userId is a UPN. I also tried using objectid of the user but I keep getting below error message.

Update-MgDeviceManagementManagedDevice : Cannot process argument transformation on parameter 'Users'. Cannot convert

value "[Microsoft.Graph.PowerShell.Models.IMicrosoftGraphUser]Microsoft.Graph.PowerShell.Models.MicrosoftGraphUser" to

type "Microsoft.Graph.PowerShell.Models.IMicrosoftGraphUser[]". Error: "Cannot convert the

"[Microsoft.Graph.PowerShell.Models.IMicrosoftGraphUser]Microsoft.Graph.PowerShell.Models.MicrosoftGraphUser" value of

type "System.String" to type "Microsoft.Graph.PowerShell.Models.IMicrosoftGraphUser"."

At line:1 char:101

  • ... 0895 -Users [Microsoft.Graph.PowerShell.Models.IMicrosoftGraphUser]$u ...

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidData: (:) [Update-MgDeviceManagementManagedDevice], ParameterBindingArgumentTrans

   formationException

    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Update-MgDeviceManagementManagedDevice

I've been trying to find some references I can find about "Microsoft.Graph.PowerShell.Models.IMicrosoftGraphUser[] but I can't find anything. I am also not sure why it is trying to convert a string to "Microsoft.Graph.PowerShell.Models.IMicrosoftGraphUser[].

Any advise or help is much appreciated!

Thank You

Windows for business | Windows Server | Windows cloud | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-01-22T01:13:18+00:00

    Hello Neo_051,

    Thank you for posting in Microsoft Community forum.

    From the description above, I understand your question is related to Intune.

    Since there are no engineers dedicated to Intune in this forum. in order to be able to get a quick and effective handling of your issue, I recommend that you repost your question in the Q&A forum, where there will be a dedicated engineer to give you a professional and effective reply.

    Here is the link for Q&A forum.
    Questions - Microsoft Q&A

    Click the "Ask a Question" button in the upper right corner to post your question and select "Microsoft Intune" tag and any other tags related to your productions.

    I hope the information above is helpful.

    If you have any question or concern, please feel free to let us know.

    Best Regards,
    Daisy Zhou

    Was this answer helpful?

    0 comments No comments