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.
This will update three Active Directory attributes.
You can view these attributes with the Attribute Editor or with PowerShell.
To update the country code using PowerShell or a 3rd party tool you must update all three attributes or else the update will fail.
For example, if you used the PowerShell set-aduser cmdlet 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 code 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 country code from the ISO website
Get the c and countryCode values 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: Setup CSV file
Download the provided CSV template from the user bulk updater tool. These attributes are already included in the template, you will need to add the users and values to be updated.
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: Run Updater Tool
The last step is to run the Bulk Updater Tool. Select your CSV file and click the run button.
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.
You can run the command below to verify the values for each user
get-aduser -Identity adam.reed -Properties * | select name, c, co, countryCode
To use the graphical tool select export users and click run.
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.