ISO CA US UK - the PowerShell Active Directory Country Gotcha

by Ed Sparks

While writing some PowerShell scripts to update a few Active Directory fields en-masse, we discovered a distinct lack of documentation on updating address information; particularly the country field.

While it appears these fields would be free-form text (as they are when editing through AD GUI tools), through PowerShell they are actually normalized and must be in the ISO Country Code format!

So, using "Canada" as a country will not work.  Rather you must use CA.  Which isn't California.

Failing to use one of the ISO codes will result in PowerShell throwing invalid errors when it writes the AD object.

Here is a list of the ISO country codes.

Here is a good Technet script for copying AD properties, as well.