Many of the day-to-day tasks involving device objects in Microsoft 365 Intune require you to filter out a subset of the available inventory in order to apply a given action or create a report. Below is a streamlined guide to list, filter, update, or bulk-edit those attributes with the Graph SDK for PowerShell.
Inside this article:
This guide explains how to manage Intune device extension attributes using Microsoft Graph PowerShell. It covers the roles and permissions required to access and modify these attributes; how to authenticate and establish a session; and how to report, filter, and update attribute values across your device inventory. Learn how to handle common SDK quirks, perform bulk operations, and query extension attributes reliably—even when dealing with inconsistent API behavior. Whether you're auditing devices or applying metadata for automation and scoping, this article provides actionable, tested PowerShell commands to manage your Intune devices.
One of the easiest ways to apply such filters is based on the set of “custom attributes” that the Microsoft Graph exposes via the extensionAttributes resource. Known as CustomAttribute1-15 or extensionAttribute1-15, they are quite useful in scenarios where you need a quick and easy way to stamp additional metadata on devices, especially if you are not using Intune and its scoping functionalities.
Let’s take a look at how we can list, manage or report on said attributes via the Graph SDK for PowerShell.
Setting policies or tagging devices for security compliance? See our guide on advanced Intune security best practices.
There are some prerequisites we need to meet first, as this is after all an admin functionality.
In order to be able to see the values of the extensionAttribute1-15 for device objects, any of the read-only Entra ID roles would do, but to be on the safe side, we can use the Global reader one. On the Graph API side of things, the minimum permission required is the Device.Read.All one.
When it comes to updating values for the extensionAttribute1-15, things are a bit more complicated. The minimum required role is the Intune administrator one, and when it comes to the Graph permissions required, you can use Device.ReadWrite.All, even though the official documentation lists the impersonation Directory.AccessAsUser.All scope as the minimum required one.
If using the application permissions model, the permission requirements are a bit simpler. For read-only operations all you need is the Device.Read.All scope, whereas for write operations, the Device.ReadWrite.All scope will do.
With the above in mind, here’s how to establish a session for working with device’ custom attributes via the Graph SDK for PowerShell:
Now that we know what the requirements are, here are some examples on how to read and report on custom attribute values for device objects. As mentioned above, the Graph API exposes the set of 15 custom attributes under the extensionAttributes blob. Due to the oddities in implementation, the corresponding Get-MgDevice cmdlet returns them as part of another blob, the infamous additionalProperties one. This makes the process a bit more complicated than it should be.
Here's a quick example on how to get the set of custom attributes for a given device:
As you might note from the output, only attributes that have values are displayed, due to yet another known issue with the Graph SDK for PowerShell (not handling null values properly). You might also want to get an output that only lists the extensionAttributes values and nothing else. This example should do:
Apart from having to deal with the oddities of the Graph SDK for PowerShell, the process of querying device’s extension attributes is rather simple, as you can see from the examples above. Sadly, the “specialized” Entra PowerShell module currently handles this scenario in the exact same manner, so I will not be including examples here. If you wish to use it, just replace the Get-MgDevice cmdlet with Get-EntraDevice.
If you want to export a report of all devices within the organization and their corresponding custom attributes, the following cmdlet should help:
For broader insights on building reliable Intune reports, our guide to reporting the right way in Intune covers the key components to include in your reports and best practices for reporting.
The resulting CSV file will give you a breakdown of the custom attribute values for all devices, which you can then use to quickly find or filter out devices with specific custom attribute values.
Alternatively, you can also do the filter via the Graph, so let’s examine a few examples of that:
Keep in mind that using a filter against the set of extensionAttributes is considered an advanced query, and as such has additional requirements. When leveraging the Graph SDK for PowerShell, advanced queries require the use of both the -ConsistencyLevel and -CountVariable parameters.
As another example of using filters, here is how to list all devices that have “empty” (null) value of a given extension attribute.
Thus far, we only covered “read” scenarios. Now, let’s also cover how to add or remove values for the extension attributes. Just as a reminder, there are certain permission requirements for that, so make sure you’ve followed the instructions above before trying any of the examples in this section.
Before making bulk changes to Intune attributes, review how to back up and restore your Intune configuration policies to prevent accidental misconfiguration.
Let’s start with an example of updating the value of a given extension attribute. To do that, we can leverage the Update-MgDevice cmdlet from the Graph SDK for PowerShell. Unfortunately, the cmdlet does not directly expose any parameters for working with extension attributes, so we need to leverage the blanket -BodyParameter instead.
For more complex operations, such as updating multiple extension attributes at the same time, it might be easier if you prepare the JSON payload beforehand and pass it. Here’s how:
If any of the attributes you specified in the cmdlets above already has a value, it will be overwritten with the newly provided value. Attributes that you do not include in the payload will not be updated, so you don’t have to worry about inadvertently overwriting their values.
To remove, or nullify the value of an extension attribute, you can use one of the following:
A keen-eyed observer might notice that we passed an empty string value above, instead of an actual $null. This is yet another oddity you have to be aware of, again due to the SDK’s inability to properly handle null values. In effect, Microsoft updated the backend to allow empty string values to equate to null values, and thus get the job done.
As a final example, here is how we can bulk update the value for a given extension attribute on all devices matching some criteria, such as the device being Workspace joined:
Manually tagging devices—and babysitting the scripts that do it—doesn’t scale. Miss one run and you’re out of compliance. Hand the script to the wrong person and you could wipe the wrong fleet.
If you need to off-load the heavy lifting, start here:
Or, if you prefer to skip the manual work, CoreView’s Task Automation engine turns your one-off PowerShell into a fully audited, self-resetting workflow. Get scoped execution (so operators run the script only against the devices they own), event-driven automation, and a full paper-trail built in.