country and countrycode attributes in AD

Mauro 21 Reputation points
2020-08-04T16:06:52.783+00:00

Hello, I inherited an Active Directory whose users have always been created with a powershell script. The script is not setting a value for countrycode but only for Country. Old users have also the countrycode populated while users created after a certain date, with the same script, have this attribute equal to zero. I read somewhere that countrycode is automatically calculated by AD when Country is populated based on ISO 3166 standards. Is that true? If so, my AD is not anymore populating that attribute. If not, how can I populate it? It seems with Set-ADUser I cannot populate it.
Thanks

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
5,947 questions
0 comments No comments
{count} votes

Accepted answer
  1. Hannah Xiong 6,231 Reputation points
    2020-08-05T02:55:43.01+00:00

    Hello,

    Thank you so much for posting here.

    I did the tests in my lab. Below are the results:

    1, If we select a country in the GUI of ADUC, it will assign values to c, co, countryCode attributes.

    15644-1.png

    2, The Country parameter of the Set-ADUser cmdlet assigns a value to the c attribute, but no values are assigned to the co and countryCode attributes. Besides, the country will show in ADUC on the Address tab.

    15618-22.png

    15619-2.png

    3, So we should assign valid values to all the three attributes in the powershell script, such as

    set-aduser -identity susan -Replace @{c="CN";co="China";countrycode=156}

    15646-33.png

    15638-3.png

    For any question, please feel free to contact us.

    Best regards,
    Hannah Xiong

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful