You can create complex schema extension properties for devices and then retrieve those specific properties from PowerShell. This blog post will walk you through how to do this.

  1. I created an app registration in my tenant to be the owner of my device schema extension following these instructions but for devices: Add custom data to groups using schema extensions – Microsoft Graph | Microsoft Docs One thing to point out is the docs do state that the owner property is not required, however, if you don’t specify that, then the app id in the token being used is going to be set as the owner. So, it is better to specify the owner. I also use the word “extension” in the app display name so that it is easier to find the owner. You will need the owner to query for the extensions that belong to you so this is important.

    This is my query to create the extension attribute in MS Graph Explorer:
  1. My query to update the value for my device:
  1. My powershell query to get the value ( {tenantId} = your tenant id without the curly braces):
connect-mggraph -tenantid {tenantId} -scopes directory.accessasuser.all

$device = (Get-MgDeviceById -DeviceId 613e81d5-e8a8-4d02-a2d2-e17c5d2e8f1f -Property rayxxxx_xxxxExtension,id)
($device.AdditionalProperties.Values).location

Disconnect-MgGraph
  1. Result:

PS C:\Users\raheld> $device = (Get-MgDeviceById -DeviceId 613e81d5-e8a8-4d02-a2d2-e17c5d2e8f1f -Property raxxxx_xxxxExtension,id)
($device.AdditionalProperties.Values).location

homeoffice

See Also: How to Create a New Schema Extension Using the Microsoft Graph Explorer | Azure Active Directory Developer Support Team (aaddevsup.xyz)

2 Thoughts to “Retrieve Schema Extension Values for Devices from PowerShell”

  1. Dave Smith

    Hi Ray,
    Just to be sure I’m reading this right: I make a new App Registration and use that Client ID for the Owner value when posting the new attribute?

    1. Ray Held [MSFT]

      Yes, that is correct.

Leave a Comment