?
Solved

add a comment in active directory using power shell scripts

Posted on 2013-12-17
5
Medium Priority
?
406 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 1500 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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
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…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
Suggested Courses

762 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