Solved

Export Active Directory OU

Posted on 2014-02-25
8
414 Views
Last Modified: 2014-02-25
Hello Experts,

I am attempting to export contacts of an Active Directory OU into a csv file. I've found lots of links on how to do this, but I would prefer not to install any additional software. Here is the command I am using:

Get-ADUser -Filter * -SearchBase "ou=Ou,dc=contoso,dc=com" -Properties * | Export-Csv  "c:\somefile.csv"

Unfortunately, this command exports a csv with 0 entries.

I have tried removing the -Properties * but it still exports blank.
0
Comment
Question by:zequestioner
8 Comments
 
LVL 36

Expert Comment

by:Mahesh
ID: 39886453
You can try script in below post to export OU structure

http://blog.flaphead.com/2010/09/10/powershell-to-export-ad-ou-structure/
0
 
LVL 40

Accepted Solution

by:
footech earned 500 total points
ID: 39886464
Contacts aren't users, so they wouldn't be returned by Get-ADUser.
You can try with Get-ADObject instead which will return the objects.
0
 
LVL 1

Author Comment

by:zequestioner
ID: 39886468
I would like to export the contents of the OU, which are objects with type 'Contact'.. I would like to export the name and email address of each contact in the OU.
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 1

Author Comment

by:zequestioner
ID: 39886471
ah, gotcha. Let me try ADObject....
0
 
LVL 1

Author Comment

by:zequestioner
ID: 39886684
I've requested that this question be closed as follows:

Accepted answer: 0 points for zequestioner's comment #a39886468

for the following reason:

Thanks!
0
 
LVL 14

Expert Comment

by:Justin Yeung
ID: 39886535
here is the answer

Get-Adobject -filter {ObjectClass -eq "contact"} -searchbase "your ou path" -properties TargetAddress | select-object Name,TargetAddress | export-csv -path "yourpath"
0
 
LVL 40

Expert Comment

by:footech
ID: 39886677
@zequestioner - It appears that you selected the wrong comment as the solution...
0
 
LVL 1

Author Closing Comment

by:zequestioner
ID: 39886685
Thanks!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
This article outlines the process to identify and resolve account lockout in an Active Directory environment.
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…

828 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