Change a device name in Azure AD using Microsoft Graph

Early this month, we explored how to discover device information using the Graph Explorer. Well one way we can edit that info (which is reported back into Azure AD) is with PowerShell. Let’s take a look.

If you’ve ever enrolled an Android device into Intune, you’ll notice that the device name is based on the date:

Android for Work device name

Now, that’s great for discovery, but it’s not exactly nice to look it. You would think you can go to the properties in Intune to update the Device name, but you can’t edit this field. For iOS and Windows devices, you can go into the Overview and push a Rename Device command though.

Device Name

In the Graph Explorer, we can query the device registered under my account and see ObjectID and Display Name. (Again – take a look at our post: Use Graph Explorer to discover property values for Dynamic Groups in Azure AD to learn more).

Graph API devices query

Now, if we want to edit that information, we want to use the Set-AzureADDevice PowerShell commandlet. This commandlet requires the AzureAD module – learn how to install it here:

All we need to do is connect to AzureAD in PowerShell and run the command! When you run Connect-AzureAD you’ll be prompted to sign in to your tenant:


Then, run the following command:

 Set-AzureADDevice -ObjectId "{id from Graph Explorer}" -DisplayName "{displayName from Graph Explorer}"
Set-AzureADDevice Command

No need to wait – go to Azure AD and hit refresh, and the new name will be there instantly.

Unfortunately, changing the device name in Azure AD won’t reflect back to Intune. I’ve explored most of the deviceManagement options in Graph Explorer and this just isn’t possible at the moment. If you’ve found a way to change it – let us know!

You may also like...

2 Responses

  1. Stefan says:

    I have a related question, When I import new computers into Intune via their Hash code the PC gets a “prefix-PCserialnumber” as its name,
    In our company we register all devices with a code and a specific company wide number.
    I would like to create a script which looks up te name and replaces it with a code and the prefix. I have this data availible in a CSV / Excel, how do i do this?

    PC is called “MyCompany-abcdefg” and needs to be “PC-code-123456”
    where the data in the csv would be: Serialnumber: abcdefg , Name: LT-123456

    • Janusz says:

      It sounds like you’re using Autopilot to deploy devices (because of the hash). The easiest way then to apply a device name would be to use the Apply Device Name Template option in the Autopilot profile. You can find more info here Configure Autopilot profile (Docs). Would that work for your situation?

Leave a Reply

Your email address will not be published. Required fields are marked *