How to Update Custom Attribute in Exchange Online

In modern IT environments, the need to store additional information about users is a common requirement. In Microsoft 365, attributes like `ExtensionAttribute` and `CustomAttribute` play a vital role in extending user object properties. These attributes provide a flexible way to store custom data for various use cases, from tracking special attributes to integrating with third-party applications.

Understanding the Difference between ExtensionAttribute and CustomAttribute

In Microsoft 365, attributes like `ExtensionAttribute1` through `ExtensionAttribute15` are often referred to as extension attributes. These attributes are used to store custom data and are associated with the user object in Azure AD.

On the other hand, Exchange Online introduces `CustomAttribute1` through `CustomAttribute15`, which serves a similar purpose. These custom attributes provide additional flexibility, especially when managing mailbox-related information in Exchange Online.

The primary difference between extension attributes and custom attributes lies in their historical context and intended use. Extension attributes are part of the broader Azure AD schema and are available across the Microsoft 365 ecosystem. Meanwhile, custom attributes are specific to Exchange Online and are particularly useful for managing mailbox-related information.

Example Scenario: CustomAttribute13 in Exchange Online

Let’s consider a scenario where you want to utilize `CustomAttribute13` in Exchange Online to store and manage information related to a specific project for each user. This could include project codes, departmental information, or any custom data relevant to your organization.

Update CustomAttribute Using PowerShell Script

To automate the process of updating `CustomAttribute13` for user mailboxes, we can use PowerShell along with a CSV file containing the necessary information. The script reads the CSV file, extracts the user’s User Principal Name (UPN) and the corresponding value for `CustomAttribute13`, and updates the mailbox accordingly.

# Connect to Exchange Online PowerShell
Connect-ExchangeOnline -UserPrincipalName <> -ShowProgress $true

# Path to the CSV file
$csvFilePath = "C:\Path\To\Your\File.csv"

# Read CSV file
$userData = Import-Csv -Path $csvFilePath

# Iterate through each row in the CSV
foreach ($user in $userData) {
# Extract UPN and Value from CSV
$userUPN = $user.UPN
$customAttributeValue = $user.CustomAttribute13

# Check if UPN and Value are provided
if ($userUPN -and $customAttributeValue) {
try {
# Get the user and set CustomAttribute13 value
Set-Mailbox $userUPN -CustomAttribute13 $customAttributeValue -ErrorAction Stop

Write-Host "CustomAttribute13 value added successfully for $userUPN"
} catch {
Write-Host "Error: $_"
} else {
Write-Host "Invalid data in CSV for $userUPN. Make sure UPN and CustomAttribute13 values are provided."

CSV File Format

UPN CustomAttribute13 Value1 Value2 Value3 Value4 Value5


As demonstrated, leveraging PowerShell to automate updates to custom attributes in Exchange Online can enhance efficiency and accuracy in managing user-related information. Whether you choose extension attributes or custom attributes, understanding their difference allows for more effective customization in your Microsoft 365 environment.

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More