Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Issue bulk updating Phone numbers in AD

$
0
0

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..!



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>