Export Active Directory OU

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.
LVL 1
zequestionerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MaheshArchitectCommented:
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
footechCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zequestionerAuthor Commented:
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
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

zequestionerAuthor Commented:
ah, gotcha. Let me try ADObject....
0
zequestionerAuthor Commented:
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
Justin YeungSenior Systems EngineerCommented:
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
footechCommented:
@zequestioner - It appears that you selected the wrong comment as the solution...
0
zequestionerAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Active Directory

From novice to tech pro — start learning today.