Solved

add a comment in active directory using power shell scripts

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

Expert Comment

by:Joseph Moody
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

[b]Ok so now I will show you how to add a user name to the description at login. [/b] First connect to your DC (Domain Controller / Active Directory Server) SET PERMISSIONS FOR SCRIPT TO UPDATE COMPUTER DESCRIPTION TO USERNAME 1. Open Active …
When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
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 …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

743 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now