Solved

add a comment in active directory using power shell scripts

Posted on 2013-12-17
5
386 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
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

INTRODUCTION The purpose of this document is to demonstrate the Installation and configuration of the Data Protection Manager product. Note that this demonstration was prepared on the basis of Windows OS is 2008 R2 and DPM 2010. DATA PROTECTI…
Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
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…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

770 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