?
Solved

Powershell Script to Get User DN  an

Posted on 2012-09-15
6
Medium Priority
?
4,482 Views
Last Modified: 2012-09-15
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,
0
Comment
Question by:shong1997
  • 3
  • 2
6 Comments
 
LVL 24

Expert Comment

by:yo_bee
ID: 38402052
What values are in your CSV file?
0
 
LVL 23

Expert Comment

by:Stelian Stan
ID: 38402055
try this:

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

Open in new window

0
 

Author Comment

by:shong1997
ID: 38402072
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
What Security Threats Are We Predicting for 2018?

Cryptocurrency, IoT botnets, MFA, and more! Hackers are already planning their next big attacks for 2018. Learn what you might face, and how to defend against it with our 2018 security predictions.

 
LVL 24

Expert Comment

by:yo_bee
ID: 38402078
So the name is Smith, John or jsmith
0
 

Author Comment

by:shong1997
ID: 38402136
jsmith
0
 
LVL 24

Accepted Solution

by:
yo_bee earned 2000 total points
ID: 38402145
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

Featured Post

A Cyber Security RX to Protect Your Organization

Join us on December 13th for a webinar to learn how medical providers can defend against malware with a cyber security "Rx" that supports a healthy technology adoption plan for every healthcare organization.

Question has a verified solution.

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

Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
Microsoft Office 365 is a subscriptions based service which includes services like Exchange Online and Skype for business Online. These services integrate with Microsoft's online version of Active Directory called Azure Active Directory.
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…
Loops Section Overview

862 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