Use the on-premises Active Directory PowerShell module and update the telephoneNumber attribute directly. The telephoneNumber AD attribute is a Unicode string, so the value can be written as-is from the CSV without reformatting.
Import-Module ActiveDirectory
$users = Import-Csv "C:\Temp\PhoneUpdate.csv"
foreach ($row in $users) {
$identity = $row.Users
$phone = $row.TNumber
$adUser = Get-ADUser -Filter "UserPrincipalName -eq '$identity' -or mail -eq '$identity'" -Properties telephoneNumber
if ($adUser) {
Set-ADUser -Identity $adUser.DistinguishedName -Replace @{telephoneNumber = $phone}
Write-Host "Updated $identity -> $phone"
}
else {
Write-Host "User not found: $identity"
}
}
Notes:
- CSV headers should be exactly
UsersandTNumber. -
Userscan contain either the UPN or the mail address. -
Set-ADUser -Replace @{telephoneNumber = $phone}writes the value exactly fromTNumber. - The
telephoneNumberattribute is single-valued. - The documented range upper limit for
telephoneNumberis 64 characters.
If the environment is hybrid and these users are mastered on-premises, updating the attribute in on-premises Active Directory is the correct approach so the value can sync upward.