Hi,
You need to use the -filter parameter to specify an ADUser property and the attribute should be "telephonenumber", not "telephone"
foreach ($user in $users) {
$sam = $user.SamAccountName
Get-ADUser -Filter {SamAccountName -eq $sam} -Properties * -SearchBase 'ou=Users,DC=cotm,DC=local' | Set-ADUser -Clear telephonenumber
}
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.