Usernames in Active Directory (AD) are generally not case-sensitive — but sometimes, you may want them standardized for consistency, integration requirements, or policy enforcement.
In one real-world scenario, a customer wanted all AD usernames (sAMAccountName) to be lowercase across a specific Organizational Unit (OU). Here’s a simple example of how you can accomplish this using PowerShell.
$InformationPreference = ‘Continue’
$users = Get-ADUser -Filter * -SearchBase “OU=MSHELDON,DC=T4EDEV,DC=local”
foreach($user in $users) {
try {
$user | Set-ADUser -Replace @{ sAMAccountName = $user.SamAccountName.ToLower() }
Write-Information “Updated user [$($user.SamAccountName)]”
} catch {
Write-Warning “Failed to update user [$($user.SamAccountName)]”
}
}