Link to home
Start Free TrialLog in
Avatar of N B
N BFlag for Canada

asked on

Importing spreadsheet to modify AD user properties

I need to import a spreadsheet containing phone number, fax number and telephone into our Active directory current objects for about 50 current users.
Do anyone have any script / help me how to attain this task through powershell ?

Thanks

Danny
SOLUTION
Avatar of J0rtIT
J0rtIT
Flag of Venezuela, Bolivarian Republic of image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of oBdA
oBdA

All you need is the SamAccountName of the users to change, and the properties in a csv with the respective header line.
It's easiest if the columns in the csv are named the same as the attributes in AD (or their equivalents in Set-ADUser).
As far as telephone numbers go, there is Fax, HomePhone, MobilePhone, OfficePhone.
Then it's just a matter of importing the csv and setting the AD properties.
So something like
Import-Csv -Path C:\Temp\users.csv | ForEach-Object {
	Set-ADUser -Identity $_.SamAccountName -Fax $_.Fax -HomePhone $_.HomePhone -MobilePhone $_.MobilePhone -OfficePhone $_.OfficePhone
}

Open in new window

Avatar of N B

ASKER

No i got first and last name column in this spread sheet.

Currently I am using following AD powershell command one by one which is working ... but I need to find the sam name.

get-aduser dgalet | set-aduser -streetaddress "Suite 100, 16011–116 Ave NW" -postalcode "T5M 3Y1" -Fax "780.451.0393" -Office "780.452.7720" -State "AB" -City "Edmonton"


If i can somehow do this with a loop and just using firstname and last name column somehow that would be great.
Avatar of N B

ASKER

Is there a way to execute above loop using first and last name column instead of sam name ?  to be able to pick user where first name and last name matches ?

Sorry I have not really worked on loop commands before.

thanks
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of N B

ASKER

Thank you very much oBdA, that helped me out  a lot!

Have a great day.