| Author |
Topic  |
|
|
meloao
Here To Stay
 
USA
114 Posts
Status: offline |
Posted - 12/13/2011 : 8:11:07 PM
|
|
I would like to use a CSV file to update the telephone and title attributes in the User Obects in AD. Can anyone point me in the right direction?
|
|
|
jhicks
Here To Stay
 
USA
283 Posts
Status: offline |
Posted - 12/14/2011 : 08:53:03 AM
|
| The first step is using Import-CSV to create objects you can pipe to some command to update the user object. That can be done a number of way depending on your situation. You could use the free AD cmdlets from Quest Software (Set-QADUser) or you could use the Microsoft AD Provider and the Set-ADUser cmdlet. This requires either a 2008 R2 DC or a DC running the AD Gateway service. As a last resort you could use old-fashioned ADSI. If it helps, I wrote an entire book on this topic: http://www.sapien.com/books/Managing-Active-Directory |
Jeffery Hicks Windows PowerShell MVP
http://jdhitsolutions.com.blog http://twitter.com/JeffHicks http://www.ScriptingGeek.com Now Available: Managing Active Directory with Windows PowerShell: TFM 2nd ed. |
 |
|
|
JSCLMEDAVE
Administrator
    
USA
6116 Posts
Status: online |
|
|
Xenophane
Honorable But Hopeless Addict
    
Denmark
3070 Posts
Status: online |
Posted - 12/14/2011 : 3:27:07 PM
|
Create a CSV file containing a unique identifier for the users an example could be SamAccountname, DN. The add a column for the things you want to add, and preferably name the column headers the same as the AD attributes you want to populate.
Could be something like:
Import-Csv -path c:\myCSVFile.csv | %{set-qaduser -identity $_.Samaccountname -Mobile $_.Mobile -Title $_.Title}
The above is written without access to a Windows machine with powershell, so you have to check the parameter names.
|
Microsoft Powershell MVP
SIG> George Bernard Shaw : The power of accurate observation is commonly called cynicism by those who have not got it. </SIG>
You can read my blog at www.xipher.dk |
 |
|
|
meloao
Here To Stay
 
USA
114 Posts
Status: offline |
Posted - 12/14/2011 : 7:02:36 PM
|
| Thanks for the responses. Xenophane, for your script I will need a unique identifer ie SamAccoutname. Is there a way to export the SamAccount so I can add it to my CSV import file? |
 |
|
|
jhicks
Here To Stay
 
USA
283 Posts
Status: offline |
|
|
Isaac
Here To Stay
 
USA
208 Posts
Status: offline |
Posted - 12/15/2011 : 12:13:03 PM
|
meloa,
do you mean getting all the users from AD? Try the following on your domain joined workstation: dsquery user domainroot -limit 0 | dsget user -samid -ln -fn -dn
-samid = will give all the sam account name -fn -ln = First and last names -dn Distinguished Names
|
 |
|
|
meloao
Here To Stay
 
USA
114 Posts
Status: offline |
Posted - 12/15/2011 : 12:22:42 PM
|
| Issac - yes, but I want to export the samid to a csv file. |
 |
|
|
meloao
Here To Stay
 
USA
114 Posts
Status: offline |
Posted - 12/15/2011 : 1:52:55 PM
|
| Ok, I was able to export to a file by addinn '> c:\samid.csv' at the end of the command. |
 |
|
|
Wiseman82
Old Timer
  
United Kingdom
520 Posts
Status: offline |
|
|
meloao
Here To Stay
 
USA
114 Posts
Status: offline |
Posted - 12/16/2011 : 09:17:24 AM
|
| Your program, Wiseman82, worked great! Thank you so much! |
 |
|
| |
Topic  |
|