Skip to content

Export Users From Active Directory

How to export users from Active DirectoryIn this tutorial, I will show you how to export users from Active Directory to a csv.

Exporting a list of Active Directory users is a common request I see. This is requested for a number of reasons such as, migrating users, auditing and reporting, importing to other programs and so on.

Below, I walk through two different methods for exporting users.

Export Users with PowerShell

If you’re not into PowerShell then jump to method 2 for a GUI based export option.

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.

Recommended Tool: SolarWinds Admin Bundle for Active Directory

3 Free tools, find inactive user or computer accounts  and quickly bulk import new user accounts.

Download your free copy of Admin Bundle for Active Directory

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 -patch filepath.csv

Example 1: Export all 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 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

Example 3: Export all users by name and email

This will export all users by name and their email address

get-aduser –filter * -property * | Select-object Name, mail

Example 4: Export all 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"

Related: How to export Active Directory Group Members

Export Users with Active Directory Users and Computers

This method uses the Active Directory Users and Computers console to export users.

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 a scv.

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

Yes, it worked.

How do you export all users?

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 the users I’ll need to create an LDAP query that displays them all, then I can export.

Watch this video for details.

Here is the LDAP query that I use in the video

(objectCategory=person)(objectClass=user)

If you want a PowerShell alternative then check out the AD User Export Tool I created. It is a GUI tool that makes exporting user accounts super easy.

Recommended Tool: SolarWinds Server & Application Monitor (SAM)

This utility was designed to Monitor Active Directory and other critical applications. It will quickly spot domain controller issues, prevent replication failures, track failed logon attempts and much more.

What I like best about SAM is it’s easy to use dashboard and alerting features. It also has the ability to monitor virtual machines and storage.

Download Your Free Trial of SolarWinds Server & Application Monitor. 

17 Comments

  1. Jeremy C on July 20, 2018 at 11:30 pm

    Thank you for posting this. It was very helpful for me today.

    • Robert Allen on July 23, 2018 at 6:37 pm

      No problem, glad it was helpful!

  2. ruin on July 26, 2018 at 11:06 am

    hi there
    i want to know how do i export all my users in AD with all permissions ??
    thanks

    • Robert Allen on October 19, 2018 at 11:22 pm

      What do you mean by all permissions? Are you wanting the security group membership?

  3. Dp on November 2, 2018 at 2:52 pm

    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 🙂

  4. Alliance on December 19, 2018 at 5:56 am

    Excellent thank you much

    • Robert Allen on December 19, 2018 at 9:03 pm

      No problem

  5. CH on March 15, 2019 at 7:41 pm

    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?

    • Robert Allen on March 15, 2019 at 8:38 pm

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

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

  6. CH on March 18, 2019 at 12:57 pm

    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.

    • Robert Allen on March 18, 2019 at 1:19 pm

      That attribute is userWorkstations

      • CH on March 19, 2019 at 12:49 pm

        Thanks! That worked perfectly!

  7. Jay on September 6, 2019 at 1:03 am

    I wanna to export from a particular active directory not all active directories

    • Robert Allen on September 7, 2019 at 8:25 pm

      Do you mean from a specific OU?

  8. Daniel on October 28, 2019 at 4:08 am

    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

    • Robert Allen on October 29, 2019 at 11:48 pm

      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

Leave a Comment