How to Update Country Codes in Active Directory

In this tutorial, I’ll show you how to bulk update the country code in Active Directory.

Using the Active Directory Users and Computers console this is easy to do for a single user. Just open a user account and change the Country/region.

Update country in active directory

This will actually update three attributes.

c:
co:
countryCode:

You can view these attributes with the Attribute Editor or with PowerShell.

When using PowerShell or a 3rd party tool all three attributes must be set or else the update will fail. For example, if you used PowerShell and tried to update just the co attribute it will fail.

Below I’ll walk through an example using the AD Bulk User Updater Tool.

Example: Bulk Update AD Users Country Code

In this example, I will bulk update the country attribute for 50 users. I’m going to update the country to “United States”. You don’t have to set every user to the same value.

Step 1:

Get the c and countryCode value from the ISO country code page. You must use these ISO 3166 country codes or the update could fail.

Searching the website for the United States I find “US” for the c attribute and “840” for the countryCode. The co attribute can be anything so I’ll use “United States”.

If any of these 3 attributes are missing the update will fail, this is also true if using PowerShell.

Step 2:

Next, update the CSV template that will be used with the Bulk Updater. These attributes are already included in the template that is provided with the toolkit.

Above, is a screenshot of my CSV template, column A is the user accounts I want to update followed by the c, co, and countryCode attributes. Save your CSV file and move to step 3.

Step 3:

The last step is to run the Bulk Updater Tool.

Check the logs for errors.

Above you can see I got an error on user Mikel.Johnson. Looking at the CSV this user is missing values for the c and countryCode columns. I did this on purpose to show you that all three attributes are required by Microsoft.

All done. That is how you bulk update the Country value in Active Directory.

If you want to try the bulk updater GUI tool you can download a free trial here. The bulk updater is one of several Active Directory tools included in the toolkit.

Recommended Tool: Hybrid Cloud Monitor

The Hybrid Cloud Monitor tool is designed to monitor and analyze IT infrastructure across on-premises and multi-cloud environments.

Monitor Azure, Active Directory, virtual and physical servers, manage IP addresses, log management and analysis, network flow and bandwidth graphs, and much more.

Get end-to-end visibility, analytics, and performance monitoring from a single web dashboard.

Leave a Comment