Change Active Directory users country code via PowerShell

on

In order to have correct information in Office 365 when using Azure AD, your users need to have a country code in Active Directory, specially when configuring self-service password reset:

$Users = Get-ADUser -Filter {samaccountname -like "*"}

foreach ($User in $Users) 
    {
        Set-ADUser -Identity $User -Country "US"
    }
Get-ADUser -Filter {countrycode -eq 0} | Set-ADUser -Replace @{countrycode=1}

 

Was this helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *