Script to update ExtensionAttribute1 in AD for a CSV

Hi I have a CSV containing Given Name, Surname, SamAccountNames and ExtensionAttribute1. I am trying to write a script that will read the spreadsheet and update the ExtensionAttribute1 for each user. I understand how to do it on a user by user basis, I just don't know how to get it to read from the csv. I have included a example of the spreadsheet I am trying to read off. Any help would be appreciated.

Thanks in advance
Who is Participating?
Joshua GrantomSenior Systems AdministratorCommented:
This should be all you need. Just make sure that your file is actually in CSV format and that your headers in the CSV do not contain extra spaces at the end like the sample file you uploaded, that causes issues with the import

Import-Module ActiveDirectory
$users = Import-CSV "C:\EEQ.csv"
ForEach ($user in $users) {
Set-ADUser -Identity $user.SamAccountName -Replace @{extensionAttribute1 = $user.ExtensionAttribute1}

Open in new window

MattyS82Author Commented:
Looks like the file didn't attach EEQ.xlsx
MattyS82Author Commented:
Great!! Thank you so much for your help.
Joshua GrantomSenior Systems AdministratorCommented:
Glad to help!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.