Welcome to Microsoft Q&A!
Thank you for providing the detailed information.
You can use the Active Directory PowerShell module to import the CSV and update the telephoneNumber attribute directly. The telephoneNumber attribute is stored as a string, so values such as +1(234) 567-1234 or +11234567893 are written exactly as they appear in the CSV without any reformatting. The telephoneNumber LDAP attribute is also exposed as the OfficePhone property in the Set-ADUser cmdlet.
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'"
if ($adUser) {
Set-ADUser -Identity $adUser `
-Replace @{telephoneNumber = $phone}
Write-Host "Updated $identity -> $phone"
}
else {
Write-Warning "User not found: $identity"
}
}
CSV example
Users, TNumber
******@contoso.com,+1(234) 567-1234
******@contoso.com,+11234567893
Notes:
- The CSV headers must be Users and TNumber.
- The Users column can contain either the user's UPN (UserPrincipalName) or email address (mail).
- Set-ADUser -Replace @{telephoneNumber = $phone} updates the telephoneNumber attribute directly and preserves the value exactly as stored in the CSV.
- In hybrid environments where identities are mastered on-premises and synchronized to Microsoft Entra ID through Azure AD Connect, updating the attribute in on-premises Active Directory is the supported approach.
If the information provided is helpful, please click Accept Answer.
Thank you for choosing Microsoft Q&A!