I'm wondering if someone can help, I'm trying to import and replace telephone numbers in AD via a Powershell script from an exported and updated CSV file.
The script I'm using is:
Import-Csv C:\test2.csv | ForEach-Object {
Set-ADUser -Identity $_.samAccountName -Replace @{
telephoneNumber=$_.OfficePhone;HomePhone=$_.HomePhone;MobilePhone=$_.MobilePhone}
}
The formatting of the CSV is:
samaccountname,OfficePhone,HomePhone,MobilePhone
Username,Phone no, phone no, phone no
When trying to import it I get the error:
C:\Users\account\Desktop\ps2.ps1:2 char:13+ Set-ADUser <<<< -Identity $_.samAccountName -Replace @{telephoneNumber=$_.OfficePhone;HomePhone=$_.HomePhone;Mobil
ePhone=$_.MobilePhone}+ CategoryInfo : InvalidOperation: (1305:ADUser) [Set-ADUser], ADInvalidOperationException+ FullyQualifiedErrorId : replace,Microsoft.ActiveDirectory.Management.Commands.SetADUser
Does anyone have any idea? I'm losing my mind with this!
Many thanks in advance..!