Solved

add a comment in active directory using power shell scripts

Posted on 2013-12-17
5
390 Views
Last Modified: 2014-01-02
HI guys,

I need to run a script, add a comment in each user profile in AD 2008 in description field .this will be using a csv file

Is any way I can do that ?

Thanks
Rabih
0
Comment
Question by:Rabihhaj
[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
5 Comments
 
LVL 22

Expert Comment

by:Joseph Moody
ID: 39724991
That isn't possible...

Just kidding! Can you share the format of your CSV? If not, this script should get your started:

$CSV = import-csv .\users.csv

foreach ($User in $CSV){
Get-QADUser $User.Username | Set-QADUser -Description $User.Comment}

Open in new window


It assumes that your CSV has two columns. One with a username and the other with a comment. It also uses the Quest AD cmdlets.
0
 
LVL 15

Expert Comment

by:WalkaboutTigger
ID: 39725007
I would suggest reading
http://dmitrysotnikov.wordpress.com/2008/10/03/update-active-directory-user-accounts-from-csv-file/
which discusses updating AD User accounts from a CSV file.

You will need to download the ActiveRoles powershell addon from
http://www.quest.com/powershell/activeroles-server.aspx
0
 
LVL 53

Accepted Solution

by:
Will Szymkowski earned 500 total points
ID: 39725069
You can use Native Powershell commands to accomplish this. Use the below syntax...

CSV File should look like below...
sAMAccountName             Description
jsmith                                    info1
ptooth                                    test description
miked                                     hr dept
etc...

Import-module activedirectory
$ModUser = import-csv "c:\youCSVhere.csv"
foreach ($user in $ModUser) {
$User.sAMAccountName
$User.Description
Set-ADUser -Identity $User.sAMAccountName -description $User.Description
}

Open in new window


Will.
0
 

Author Comment

by:Rabihhaj
ID: 39727742
Hi will,

Could you please explain each line, 5 years ago did c++.
I would like to learn ps.



Thanks Rabih
0
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 39728028
See below...
line1 = importing the active directory module into the powershell session
line2 = creating a variable for importing the csv file into the powershell session
line3 = foreach user in the csv file
line4 = Bind $user to sAMAccountName (heading in csv file)
line5 = Bind $user to Description (heading in the csv file)
line6 = set the AD user description foreach object in the csv file
line7 = closing bracket

The command runs individually for each user you put in the csv file.

Will.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

This article runs through the process of deploying a single EXE application selectively to a group of user.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

763 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