Link to home
Start Free TrialLog in
Avatar of Fred Acme
Fred Acme

asked on

Export all Country of Active Directory

Good morning,

I've got a problem with the country name in Active DirectoRY.
When I create an account with the country digit (FR or UK for example) with PowerShell, the name doesn't appear in Outlook or in "co" or "countrycode" in LDAP.

I saw it's normal because I need to enter the 3 informations in my script.

So, I would like to export the list of country, countrycode and country digit to use the same as my AD.
I found a list on Wikipedia and on https://www.iso.org/obp/ui/#search but they're not the same.

Was it possible to export all of this informations from Active Directory ?

Thank you for your help.

Fred
Avatar of Shaun Hardneck
Shaun Hardneck
Flag of South Africa image

Good Day , you looking just to export the Country and CountryCode field from AD, then you can use the below.

Get-Aduser -Filter * -Properties * |ft Name,Country,CountyCode |Out-File C:\Softlib\AdExport.csv

Open in new window


and then it will export to csv
Avatar of Fred Acme
Fred Acme

ASKER

Hello Shaun,

It's not that.
I need to export the complete list of country and country codes included in AD.

For example, I don't have an account in Malawi, but I want to know the differents informations about this country in AD (Digit ? Complete name ?  Numeric ?)

In AD, I have "Serbia and Montenegro (Former)", but in the ISO list, it's an old information.
If I want to create scripts with a new country, It's complicated to search informations about it.

Thank you for your answer :)
ok :) I follow apologies . let me see what I can get
ASKER CERTIFIED SOLUTION
Avatar of Shaun Hardneck
Shaun Hardneck
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@shaun don't put the format-list (fl) before your selection use

Get-ADUser -filter * -Properties * | Select-Object name,country,countrycode | fl
also |Out-File C:\Softlib\AdExport.csv will not result in a proper csv
Name                     Country CountyCode
----                     ------- ----------
Administrator                    {}        
Guest                            {}        
DefaultAccount                   {}        
krbtgt                           {}        
David W.

Open in new window

and don't use fl before an out-file or exportto-csv
Hello Shaun,

Thank you for links.
I think, I've got 99% of informations.

A colleague found an alternative solution.
With AD, we have to enter the 3 informations about a country.
With Exchange (2010 in my case), with the PowerShell command : Set-user user -Country "US" for example, it's OK.
We don't need to enter more data to have the good result :)

Have a nice day,
Fred