Assign extension attributes to Entra ID devices using Graph and PowerShell

Managing devices in Microsoft Entra ID often requires assigning custom attributes to devices for better organization and management. This blog post will guide you through a PowerShell script that assigns extension attributes to Entra ID devices. Please be aware that this script leverages the Microsoft Graph API and requires specific permissions to execute.

Requirements

Before running the script, ensure you have the following:

  • Microsoft.Graph.Beta PowerShell module
  • Permissions: Directory.ReadWrite.All and Device.Read.All

Script Overview

The script connects to Microsoft Graph, retrieves a specific device, assigns extension attributes, and provides an option to clear these attributes if needed.

Script Details

Connect to Microsoft Graph

First, the script connects to Microsoft Graph using the required scopes:

Retrieve the Device

Next, the script retrieves the device based on its display name. Make sure to replace DeviceDisplayName with the actual display name of the device you want to manage:

Set Extension Attributes

The script then sets the variables for the extension attributes you want to assign:

Assign Extension Attributes

The extension attributes are assigned to the device using the following code:

Clear Extension Attributes

If you need to clear the extension attributes, the script provides an option to do so:

Conclusion

This script simplifies the process of assigning and managing extension attributes for Entra ID devices. By using the Microsoft Graph API and PowerShell, you can efficiently manage device attributes, enhancing your organization’s device management capabilities.

Script Source

Complete script as always is available for download on Azure365Addict GitHub.
Feel free to customize the script to fit your specific needs and improve your device management processes.

If you have any questions or want to extend this into automated cleanup or reporting, feel free to reach out.

Happy scripting!

Leave a Comment

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

Scroll to Top