Export AD Users to CSV

In this tutorial, I will show you how to export Active Directory Users to a CSV file.

I’m going to show you three options.

  1. Export Users with GUI Tool (Export all Users, from an OU or a group)
  2. Export AD Users with PowerShell
  3. Export Users using the ADUC Console

Let’s get started.

Step 1: Open the AD User Export Tool

This first option uses the AD User Export Tool.

Click here to download a free trial.

You will see in the example below that this is the easiest option for exporting users from Active Directory.

Step 2: Choose Path to Export

In the search criteria box pick where you want to export from, you can pick the following:

  • Entire Domain – This will export all users in your domain
  • Select OU or Group – This allows you to select one or multiple OUs or groups to export.

In this example, I’m going to export all users from my Accounting OU and HR OU. Click the browse button and select what you want to export.

Step 3: Pick AD User Fields to include in the Export

By default, the export tool includes 27 user attributes in the export. You can click the change columns button to add or remove user fields.

For this example, I’m going to leave the default fields selected. You can always remove unwanted fields after exporting by deleting the columns in the CSV file.

Step 4: Click the Run button to preview the export

The last step is to click the export button. Select your format and click “Export All Rows”

You will be prompted to save the file. Give the file a name and save it to your computer.

Here is an example export.

One nice feature of the GUI tool is it will include the user’s group membership. 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.

I think we can all agree the GUI Tool makes it very easy to export users to a CSV file. It gives you the flexibility to pick exactly which users to export and what details to include in the export.

Now let’s check out how to export users with PowerShell.

Option 2: Export AD Users to CSV With PowerShell

To export users with PowerShell the AD Powershell module needs to be loaded.

If you have the RSAT tools installed or access to a server with the AD RS role installed then you are all set.

First, you need to determine what user attributes to export. If you want just the username you can use the name attribute (example below)

To get a list of all the user’s attributes run this command on one user

get-aduser username -Properties *

This will display a lot of information but it will help you determine what to export. Ok, let’s look at some examples.

To export these results to a CSV just add | export-CSV -path filepath.csv

Example 1: Export All AD Users by Name

This command will export all users by name

Get-ADUser -Filter * -Properties * | Select-Object name | export-csv -path c:\export\allusers.scv

Example 2: Export All AD Users by name and lastlogondate

The command will export all users by name and their last logon date.

get-aduser –filter * -property * | Select-object Name, LastLogonDate | export-csv -path c:\export\exportusers.csv

Example 3: Export All AD users by name and email

This will export all users by name and their email address

get-aduser –filter * -property * | Select-object Name, mail | 
export-csv -path c:\export\exportusers.csv

Example 4: Export Users from a specific OU

This will export all users from a specific OU.

Get-ADUser -Filter * -SearchBase "OU=Finance,OU=UserAccounts,DC=FABRIKAM,DC=COM" | 
export-csv -path c:\export\exportusers.csv

Example 5: Export only Enabled User accounts

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

Want more PowerShell examples? I’ve compiled a list of over 60 PowerShell AD User Reports that I recommend you take a look at.

Option 3: Export Users with Active Directory Users and Computers

This method uses the Active Directory Users and Computers console to export users. If you need a very basic export with limited user fields then this option is for you. The one problem is it is limited to a single folder.

Step 1: Open Active Directory Users and Computers

Step 2: Browse to the container that has the users you want to export.

In my test environment, I’ll be exporting the users from the HR container.

Step 3: Click the export button

Now just browse to where you want to save the file, name it and change save as type to CSV.

I’ll open the CSV file in excel to verify it exported.

Yes, it worked.

How do you export all users to CSV?

The problem with exporting users from ADUC is that it only exports users from a specific folder. If you have users organized into many different folders, you would have to export from each one of them.

To Export all Users you have two options.

  1. User Export GUI Tool
  2. PowerShell

Using the GUI tool you just select “Entire Domain”

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


Get-ADUser -Filter * -Properties * | Select-Object name | export-csv -path c:\export\allusers.scv

I just showed you 3 options on how to export AD users to a CSV file. I recommend you try them all out and see which option is best for you. The built in Microsoft console by far has the fewest options but if you just need a simple export then it works ok. PowerShell can be a great option for exporting user accounts but it can be complex and challenging at times for quick solutions. If you are not into PowerShell and need an option to export from groups, OUs, and to select which fields to export then the AD User Export Tool is a great choice.

Related: How to export Active Directory Group Members

Top 25
Active Directory
Security Checklist

Download this FREE PDF checklist that includes the top 25 best practices for securing Active Directory and Windows systems.

35 thoughts on “Export AD Users to CSV”

    • It helped me immensely today as well. I don’t have access to the AD server, but I can ‘read’ AD with the MMC app. This was the first tutorial of several I had reviewed that got me exactly what I needed. Thank you, Mr. Robert Allen!

      Reply
  1. Hey Robert,

    Thanks for putting this up. I’m curious if there is a way to list all users and all associated groups or organizational units in a single spread sheet?

    I’ve got some software that needs to auto-group users by AD Group or OU but operates outside Microsoft Active Directory. I’d love to be able to have a user generate a CSV that has person/user in a column and then what groups or OU’s they are associated with.

    Thx,

    Dave

    Reply
  2. Do you have video on import LDAP users in to AD?. I am trying to import our LDAP users to AD then to Azure. I am able to migrate from AD to Azure AD just need to work on the LDAP to AD part 🙂

    Reply
  3. I am trying to export a list of our AD users as well as their “Log On To” permissions to a CSV file. How could I do this?

    Reply
    • CH, I think that is the logonWorkstation attribute. Try this

      Get-ADUser -Filter * -Properties * | select name, logonworkstation

      Reply
  4. Actually that script isnt what I was looking for.
    What I am referring to is when you open up the properties of a user and select the “account” tab, there is a button that says “log on to” and it shows what machines on the domain that that user is allowed to log on to.

    Reply
  5. this was very useful, however I would like to get the unix attributes, such as uid and gid. These show up as {username} rather then the number when I use get-aduser username -properties *

    Reply
  6. Hi,

    Can you please tell me where I gone wrong with “Get-ADUser -Filter * -property * | Select-object Name, Title -SearchBase “OU=O365,OU=Users,DC=danielx64,DC=com,DC=au” | export-csv -path c:\export\allusers.csv”?

    Cheers

    Reply
    • Daniel,

      The -searchbase is in the wrong place. Try this

      Get-ADUser -Filter * -SearchBase “OU=O365,OU=Users,DC=danielx64,DC=com,DC=au” -property * | Select-object Name, Title | export-csv -path c:\export\allusers.csv

      Reply
  7. Hey Robert,

    I tried using the command, but my syntax may be wrong. Can you take a look?

    Get-AdUser -Filter * -SearchBase “OU=Digicel,OU=Bermuda,OU=Users,DC=BMU-DC-001,DC=digicelgroup,DC=local” -Property * | select-ObjectName, SamAccountName, PasswordExpired, PasswordLastSet, LastLogonDate, Enabled, DistinguishedName, DisplayName, GivenName, SurName|export-csv C:\Documents\output.csv

    Thanks,

    Reply
  8. Hi, question from support perspective.
    If you’re exporting all users and an extension attribute within an organization, would this have any impact on the users at all? Is it possible to slow down the system enough to impact users logging into the same servers?

    Reply
    • With the AD Pro Toolkit, I exported about 3000 users and it took 10 seconds. While it was running the domain controller CPU went from 7% to 30% for those 10 seconds. My test server has 1 CPU with 2GB ram, a very small server. In production, I would recommend 2 CPUs and at least 4GB ram.

      PowerShell uses very little CPU but took about 1 minute to export 3k users.

      Neither option should impact users logging in but that depends on the CPU/Mem usage before its run. What does your CPU/Mem usage show before running an export?

      Reply
    • Hi
      I would need to export all users who do not have the extensionAttribue1 “Azuresync” what is the powershell command

      Tanks

      Reply

Leave a Comment