Export AD Users to CSV with PowerShell (2024)

In this tutorial, I’ll show you two options on how to export Active Directory Users to CSV. I’ll also show you how to export users from an OU, and get specific user attributes like last logon, email addresses, state, city, and so on.

In this article:

  • Option 1. Export AD Users to CSV with the AD Pro Toolkit
  • Option 2. Export AD Users to CSV with PowerShell
  • How to Export All Users from Active Directory

In this first example, I’ll Export Users with the AD Pro Toolkit. You can Download a free trial of this tool and try it for yourself.

Step 1. Under User Management click on “Export Users”.

Export AD Users to CSV with PowerShell (1)

Step 2. Click “Browse” to select an OU or group or leave the default to export all users.

Export AD Users to CSV with PowerShell (2)

Step 3. Click “Columns” to add or remove user attributes. You can also include custom attributes by clicking the “Add Custom Attribute” button.

Export AD Users to CSV with PowerShell (3)

Step 4. Click “Run” to generate a list of users.

Step 5. Click “Export” to export the list of users to CSV. Alternatively, you can select to export to Excel or PDF.

Export AD Users to CSV with PowerShell (4)

Below is an example from my export. So for each user, it will show you which security groups they are a member of. Of course, you can just uncheck “memberOf” in the columns picker if you don’t want to see this info.

Export AD Users to CSV with PowerShell (5)

Option 2. Export AD Users to CSV with PowerShell

Here are the steps to export Active Directory users to CSV using PowerShell.

Step 1: Get-ADUser PowerShell Command

To export users with PowerShell, the Get-ADUser cmdlet is used. This command will get user accounts from Active Directory and display all or selected attributes. It’s important to know how this command works so you can export the data you need.

The most important thing to remember is how to display all the user attributes. This will come in useful when you want to export only specific account details.

The below command will get all user attributes for a single user.

get-aduser -identity username -Properties *

Change the “username” to a user in your domain.

Pay attention to the left column. These are the user attribute names and the values on the right. In example 4, I’ll show you how to select specific attributes to include in the export.

Export AD Users to CSV with PowerShell (6)

Related: How to bulk modify user attributes

Step 2: Export to CSV command

Add “export-CSV -path” to the end of the command to export to a CSV file. See the below example, I’m exporting all the properties for this user to c:\temp\export.csv.

get-aduser -identity username -Properties * | export-csv -path c:\temp\export.csv
Export AD Users to CSV with PowerShell (7)

You should now have a CSV export of all user properties for a single user.

Step 3: Export specific user attributes

If you don’t want to export all user attributes then use the “select-object” command and enter only the attributes you need. If you have followed along from the beginning then you know how to find the attribute names, if not then jump to example 2.

In the below example I’ll export the DisplayName, City and State.

get-aduser -identity username -Properties * | select DisplayName, City, State | export-csv -path c:\temp\export.csv

Step 4: How to export all users

To export all users remove (-identity) and add (-filter *) to the command. In the below example I’m exporting all users and selecting displayname, city, company, department, EmailAddress, and telephonenumber.

get-aduser -filter * -Properties * | select displayname, city, company, department, EmailAddress, telephonenumber | export-csv -path c:\temp\export-all.csv

Here is what this looks like in PowerShell.

Export AD Users to CSV with PowerShell (8)

Here is the CSV.

Export AD Users to CSV with PowerShell (9)

Step 5: Export Users from a specific OU

Export AD Users to CSV with PowerShell (10)

To export users from specific OUs use the “-SearchBase” command and the “distinguishedName” value of the OU.

In the below example I’m getting all the users in my accounting OU.

Get-ADUser -Filter * -Properties * -SearchBase "OU=Accounting,OU=ADPRO Users,DC=ad,DC=activedirectorypro,DC=com" | select displayname, DistinguishedName, Enabled

Here is the PowerShell output.

Export AD Users to CSV with PowerShell (11)

Then add export-csv -path to the end to export this to CSV.

Get-ADUser -Filter * -Properties * -SearchBase "OU=Accounting,OU=ADPRO Users,DC=ad,DC=activedirectorypro,DC=com" | select displayname, DistinguishedName, Enabled | export-csv -path c:\temp\export-ou.csv

At this point, you should be able to export single, all users, or users from a specific OU. I also showed you how to export all or specific user attributes.

Below are a few more PowerShell examples.

Export only enabled users

To get just the enabled user accounts you need to add a filter that searches for enabled = true.

Get-ADUser -Filter {Enabled -eq $true} -properties * | select-object samaccountname,givenname,surname,Enabled | export-csv -path c:\export\exportusers.csv

Export users to CSV with last logon date

get-aduser -Filter * -Properties * | select displayname, LastLogonDate | export-csv -path c:\temp\export_lastlogon.csv

How to Export All Users from Active Directory

To export all users from Active Directory, follow these steps.

  1. Open the Export Users Tool
  2. Click “Run”
  3. Click the “Export” button and select CSV.
  4. Optionally, click the Columns button to add or remove attributes.
Export AD Users to CSV with PowerShell (12)

With PowerShell, the below command will export all users to CSV. This will just export the user’s name, you will need to add additional attributes as needed.

Get-ADUser -Filter * -Properties * | Select-Object name | export-csv -path c:\export\allusers.csv
Export AD Users to CSV with PowerShell (2024)
Top Articles
How is my money on Stash protected?
Leverage: Increasing Your Real Estate Net Worth
Craigslist Myrtle Beach Motorcycles For Sale By Owner
This website is unavailable in your location. – WSB-TV Channel 2 - Atlanta
Canya 7 Drawer Dresser
Craigslist Motorcycles Jacksonville Florida
What Happened To Dr Ray On Dr Pol
Www.craigslist Augusta Ga
Dr Lisa Jones Dvm Married
How to Type German letters ä, ö, ü and the ß on your Keyboard
Volstate Portal
Flat Twist Near Me
Visustella Battle Core
Mndot Road Closures
Aries Auhsd
Does Pappadeaux Pay Weekly
Prices Way Too High Crossword Clue
4156303136
How Quickly Do I Lose My Bike Fitness?
Why Is Stemtox So Expensive
Everything You Need to Know About Holly by Stephen King
United Dual Complete Providers
Les Schwab Product Code Lookup
Missed Connections Dayton Ohio
Cinebarre Drink Menu
Khiara Keating: Manchester City and England goalkeeper convinced WSL silverware is on the horizon
Jayah And Kimora Phone Number
Amazing deals for DKoldies on Goodshop!
Where to eat: the 50 best restaurants in Freiburg im Breisgau
Gina Wilson Angle Addition Postulate
Disputes over ESPN, Disney and DirecTV go to the heart of TV's existential problems
No Limit Telegram Channel
Weather October 15
Yayo - RimWorld Wiki
Indiana Immediate Care.webpay.md
Agematch Com Member Login
Delaware judge sets Twitter, Elon Musk trial for October
Registrar Lls
Panorama Charter Portal
Craigslist Boats Dallas
Exam With A Social Studies Section Crossword
Penny Paws San Antonio Photos
4k Movie, Streaming, Blu-Ray Disc, and Home Theater Product Reviews & News
Borat: An Iconic Character Who Became More than Just a Film
Muni Metro Schedule
Best Restaurant In Glendale Az
Ronnie Mcnu*t Uncensored
Zadruga Elita 7 Live - Zadruga Elita 8 Uživo HD Emitirani Sat Putem Interneta
Craigslist Pets Lewiston Idaho
Parks And Rec Fantasy Football Names
Selly Medaline
Heisenberg Breaking Bad Wiki
Latest Posts
Article information

Author: Rubie Ullrich

Last Updated:

Views: 6374

Rating: 4.1 / 5 (52 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Rubie Ullrich

Birthday: 1998-02-02

Address: 743 Stoltenberg Center, Genovevaville, NJ 59925-3119

Phone: +2202978377583

Job: Administration Engineer

Hobby: Surfing, Sailing, Listening to music, Web surfing, Kitesurfing, Geocaching, Backpacking

Introduction: My name is Rubie Ullrich, I am a enthusiastic, perfect, tender, vivacious, talented, famous, delightful person who loves writing and wants to share my knowledge and understanding with you.