Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Update Users Properties in Active Directory by Script and CSV

Posted on 2015-02-08
6
Medium Priority
?
58 Views
Last Modified: 2015-03-19
Dear All,

I’m looking for a help to update all users properties and date in active directory (phone number, mobile number, department, office ... etc), i'm looking for help to find a script which can do this.


Please help.

Thanks
0
Comment
Question by:Rhala
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 40596804
Do you have the users sAMAccountName in the CSV? Construct the csv file like below...

CSV Example
sAMAccountName    department    Office          phone              mobilephone
dsmith                         accounting      highbury    xxx-xxx-xxxx   xxx-xxx-xxxx
etc....

Import-module activedirectory
$Changes = import-csv "c:\yourcsvhere.csv"
foreach ($User in $Changes) { 
$User.sAMAccountName
$User.department
$User.Office
$User.phone
$User.mobilephone
Set-Aduser -Identity $User.sAMAccountName -Department $User.department -Office $User.Office -OfficePhone $User.phone -MobilePhone $User.mobilephone
}

Open in new window


That should do it.

Will.
0
 
LVL 83

Expert Comment

by:David Johnson, CD, MVP
ID: 40596809
something along this line will work
update-users.ps1
$users = import-csv -path c:\scripts\update-users.csv
foreach ($user in $users){
Set-ADUser -Identity $user.samaccountname> -MobilePhone $user.mobile -OfficePhone $user.officephone
}

Open in new window

update-users.csv
samaccountname,mobile,officephone
johndoe,123-456-7890,789-123-1234x1234

Open in new window


https://technet.microsoft.com/en-us/library/hh852287.aspx
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 40597312
Not all properties are available with Set-AdUsers directly, but the common ones are. If you have difficulties to find the parameter names, post back with the details.
0
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 

Author Comment

by:Rhala
ID: 40600431
thanks all,

does what you mentioned will overwrite what exists in AD?

also, is there a list of all AD properties in one CSV file which i can include all info and them update it one time
0
 

Author Comment

by:Rhala
ID: 40600456
Hi All,

I found the below script which it seems it can do some work:
https://gallery.technet.microsoft.com/scriptcenter/Feeding-data-to-Active-0227d15c/view/Discussions#content

i need to ask how i can add or delete prosperities to the CSV file and then update the script based on that
0
 
LVL 71

Accepted Solution

by:
Qlemo earned 2000 total points
ID: 40637153
The script in the link is using Quest tools to do the work. This can be done the same without Quest if the ActiveDirectory PowerShell module is available. But:

1. You never want to have a CSV containing all possible AD attributes. You focus on a few, e.g. all address related ones. Anything else is getting far off course, prone to errors, impractical, or in short a mess.

2. Most AD attributes may not be set to empty/null, and trying to do so will end in error messages stopping from applying any change. A script offering to set attributes optionally needs to check for values, and use a different syntax for deleting or replacing (combined) or adding (combined) setting values.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

OfficeMate Freezes on login or does not load after login credentials are input.
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question