Powershell get 2 letter ISO code for country

Iron Contributor

Hallo,

 

when I use this powershell code

$User = Get-AzureADUser -Filter "userPrincipalName eq 'Mail'"

$User.country

 

I get as Output "GERMAY". How I have to change the code to get "DE" (2 letter ISO code) as output.

 

Thanks

Stefan

1 Reply

The abbreviated ones represent the "c" attribute, but if I remember correctly that one is never surfaced in AAD/Graph. Instead, you can simply make your own mapping in accordance to ISO 3166-2 (https://en.wikipedia.org/wiki/ISO_3166-2) or just "borrow" some of the code samples available online 🙂