set telephone number powershell in ad code example
Example: powershell script to change phone number in ad
$users = get-aduser -filter * -searchbase "OU=TestScript,OU=UK,OU=SomeDomain,DC=ad,DC=SomeDomain,DC=com"`
-Properties telephonenumber, mobile
foreach ($user in $users) {
#Make changes to phone number and place the results into variable $phoneupdate
$phoneupdate = ($Users.telephonenumber -replace "\(0\)", "" -replace "[^0-9,^+]", "")
Set-ADUser $user -add @{telephonenumber=$phoneupdate}
}