Administrators can use the Microsoft Graph profileCardProperty resource to add extensionAttribute1 – 15 to a Microsoft 365 Profile Card. There are many descriptions on the web of how to add custom properties to a profile card.
Just some lines of code.
Connect-MgGraph -Scopes PeopleSettings.ReadWrite.All
$Body = @"
{
"directoryPropertyName": "CustomAttribute8",
"annotations": [
{
"displayName": "Cost center",
"localizations": [
{
"languageTag": "de-CH",
"displayName": "Kostenstelle"
},
{
"languageTag": "fr-CH",
"displayName": "Centre de coûts"
},
{
"languageTag": "it-CH",
"displayName": "Centro di costo"
}
]
}
]
}
"@
$Url = "https://graph.microsoft.com/v1.0/admin/people/profileCardProperties"
$Result = Invoke-MgGraphRequest -Method POST -Uri $Url -Body $Body -ContentType "application/json"
The sample worked in the past, but now the API returns an error message stating that the language is not supported.
[\”Locale ‘de-CH’ is not supported.\”,\”Locale ‘fr-CH’ is not supported.\”,\”Locale ‘it-CH’ is not supported.\”]
The documentation on how to update the profile card now includes samples with a language code (de, no, ru,…) compared to a regional language code (de-CH, de-DE, fr-CH,…) some months ago.
The page version history includes a commit from February 2024, which notes that the regional language code has changed to language code. All the samples were modified.
I tried the same example with just the language code.
Remember to add the charset in your request; otherwise, special characters (like that in the French name) may be displayed incorrectly.
Connect-MgGraph -Scopes PeopleSettings.ReadWrite.All
$Body = @"
{
"directoryPropertyName": "CustomAttribute8",
"annotations": [
{
"displayName": "Cost center",
"localizations": [
{
"languageTag": "de",
"displayName": "Kostenstelle"
},
{
"languageTag": "fr",
"displayName": "Centre de coûts"
},
{
"languageTag": "it",
"displayName": "Centro di costo"
}
]
}
]
}
"@
$Url = "https://graph.microsoft.com/v1.0/admin/people/profileCardProperties"
$Result = Invoke-MgGraphRequest -Method POST -Uri $Url -Body $Body -ContentType "application/json; charset=utf-8"
The request was successful.
The Microsoft 365 Profile Card includes the Cost Center attribute in different languages during the next 24 hours.
To test the different languages, change the display language of Teams on the web. For me, it’s the fastest way to validate the attribute in different languages.