Hello
I need to update/populate my AD users with the correct telephone numbers 555-123-4567
and then copy that to the ipphone field as 91234567.
I will have an csv with smtp and telephone populated.
I was thinking 2 separate scripts:
Import-Csv C:\testfile.csv | ForEach-Object {
Set-ADUser -Identity $_.emailaddress -Replace @{
telephonenumber=$_.telephonenumber}
}
2.
Get-ADUser -Filter {(SamAccountName -like '*' -and Enabled -eq $True -and TelephoneNumber -like '*')} -SearchBase 'OU=Test_Users,DC=mydomain,DC=local' -Properties telephoneNumber | ForEach {
$telephoneNumber = $_.telephoneNumber
if ($telephoneNumber -and $telephoneNumber.Length -ge 4) {
$ipPhone = $telephoneNumber.SubString($telephoneNumber.Length - 7)
Set-ADUser -Identity $_.SamAccountName -Replace @{ipPhone = $ipPhone}
}
}
thank you