Created
August 5, 2026 01:29
-
-
Save JustinGrote/b9c85c4614229069c10cfe0b0b21ac5a to your computer and use it in GitHub Desktop.
Get ExchangeCustomAttribute via MS Graph
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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