Skip to content

Instantly share code, notes, and snippets.

@JustinGrote
Created August 5, 2026 01:29
Show Gist options
  • Select an option

  • Save JustinGrote/b9c85c4614229069c10cfe0b0b21ac5a to your computer and use it in GitHub Desktop.

Select an option

Save JustinGrote/b9c85c4614229069c10cfe0b0b21ac5a to your computer and use it in GitHub Desktop.
Get ExchangeCustomAttribute via MS Graph
function Get-MgUserExchangeAttributes {
param(
[Parameter(Mandatory)]
[Guid]$UserId
)
$attributes = (1..5).ForEach{"extension_79c86e5137c54776975dce9deb389ed4_extensionAttribute$_"}
$result = Get-MgUser -UserId $UserId -Property $attributes -ErrorAction Stop
return [PSCustomObject]@{
UserId = $UserId
ExtensionCustomAttribute1 = $result.AdditionalProperties[$attributes[0]]
ExtensionCustomAttribute2 = $result.AdditionalProperties[$attributes[1]]
ExtensionCustomAttribute3 = $result.AdditionalProperties[$attributes[2]]
ExtensionCustomAttribute4 = $result.AdditionalProperties[$attributes[3]]
ExtensionCustomAttribute5 = $result.AdditionalProperties[$attributes[4]]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment