?
Solved

Update Users Properties in Active Directory by Script and CSV

Posted on 2015-02-08
6
Medium Priority
?
57 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 82

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 70

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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

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 70

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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
Utilizing an array to gracefully append to a list of EmailAddresses
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
Suggested Courses

752 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