Powershell Script to Get User DN an

I need a Powershell script to read a text/CSV file with a list of AD user accounts and export users' distinguished name (DN) to a CSV file.  

Thanks,
shong1997Asked:
Who is Participating?
 
yo_beeConnect With a Mentor Director of Information TechnologyCommented:
Try this.  StrName is the column name. So change that according to your file.

import-module activedirectory 
clear 
import-csv c:\test.csv |Foreach-Object {Get-ADUser -Identity $_.StrName} | Select name,sAMAccountName,distinguishedName | Export-CSV C:\filename.csv

Open in new window

0
 
yo_beeDirector of Information TechnologyCommented:
What values are in your CSV file?
0
 
Stelian StanNetwork AdministratorCommented:
try this:

Import-Csv D:\test.txt | select dn | export-csv -Append -NoTypeInformation process.csv

Open in new window

0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
shong1997Author Commented:
I have an import CSV file which I use to extract other AD/Exchange info.  The CSV file contains 'Name' as the heading and user accounts are listed line by line.
0
 
yo_beeDirector of Information TechnologyCommented:
So the name is Smith, John or jsmith
0
 
shong1997Author Commented:
jsmith
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.