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

x
?
Solved

add a comment in active directory using power shell scripts

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
This process allows computer passwords to be managed and secured without using LAPS. This is an improvement on an existing process, enhanced to store password encrypted, instead of clear-text files within SQL
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Suggested Courses

597 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