How to Change Azure Device Owner with Microsoft Graph Powershell?

Jay Carper 216 Reputation points
2023-08-02T16:55:27.6633333+00:00

The AzureAD module is being retired and I know how to do this using Add-AzureADDeviceRegisteredOwner. Please read the question before replying.

I have read the documentation for New-MgDeviceRegisteredOwnerByRef, but it appears to be incomplete. I don't see anything in the instructions about how to actually add a registered owner for a device. Is this the correct cmdlet? If so, how do you use it? If not, what is the correct cmdlet?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
9,950 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
18,641 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Vasil Michev 90,881 Reputation points MVP
    2023-08-03T06:45:09.2733333+00:00

    Yes, that's the "replacement" cmdlet. And yes, the documentation leaves a lot to be desired, but that's something you have to learn to live with, then it comes to the Graph SDK :(

    Here's an example on how to use it:

    New-MgDeviceRegisteredOwnerByRef -DeviceId dd16bf84-xxxx-xxxx-xxxx-89d42328529e -OdataId "https://graph.microsoft.com/v1.0/directoryObjects/e0d7442c-xxxx-xxxx-xxxx-ec9887816677"

    where you have to specify the device ID and the desired user's ID. The "https://graph.microsoft.com/v1.0/directoryObjects/" prefix is mandatory, as those cmdlets are all autogenerated and any concept of convenience is foreign to them.

    An alternative use of the cmdlet is:

    New-MgDeviceRegisteredOwnerByRef -DeviceId dd16bf84-xxxx-xxxx-xxxx-89d42328529e -BodyParameter @{"@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/fe506ef0-xxxx-xxxx-xxxx-e82f833c3e91"}