Share via


Need help with update phone numbers in ad from csv

Question

Monday, November 5, 2018 12:28 PM

Hello all
I need to update the field "Telephone Number" in Ad for 200 Users,
and i created excel file with 2 columns
columns 1 - username
columns 2 - phone

which command can do for me this job ?

tnx

 

All replies (6)

Tuesday, November 6, 2018 2:21 AM ✅Answered

Hi,

Thanks for your question.

I suggest you create csv file with username and phone properties. Then use Import-Csv cmdlet to import csv file content.  Foreach function can help you set bulk aduser property.

For example:

$file = import-csv c:\users\administrator\desktop\alluser1.csv
foreach ($data in $file)
{
$samaccount = $data.username
$phonenumber = $data.phone
set-aduser -identity $samaccount -HomePhone $phonenumber
}

Best Regards,

Lee

Just do it.


Monday, November 5, 2018 12:42 PM

There is no single command.  You need to use Set-AdUser and Import-Csv.  See the help for these commands.

\(ツ)_/


Tuesday, November 6, 2018 12:58 PM

Hey,

I trying to do it, but i get some errors:


Tuesday, November 6, 2018 1:42 PM

Username must be "SamAccountName" and not CN.

  Csv must have headers with username and phone

import-csv c:\users\administrator\desktop\alluser1.csv |
    ForEach-Object{
        set-aduser -identity $_.username -HomePhone $_.phone
    }

Please read all of the help for both commands until you understand how it works.

\(ツ)_/


Tuesday, November 6, 2018 2:13 PM

Its works ! :)

thank you so much 


Friday, November 9, 2018 9:15 AM

Hi,

Was your issue resolved?

If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

If no, please reply and tell us the current situation in order to provide further help.

Best Regards,

Lee

Just do it.