Skip to content

Export Active Directory Users to CSV File

In this guide, you’ll learn how to export Active Directory users to a CSV file using PowerShell and Entralyzer, making it easy to report, share and audit user data.

Method 1: Export AD Users to CSV with PowerShell

Section titled “Method 1: Export AD Users to CSV with PowerShell”
  1. Log into a computer that has the Active Directory PowerShell Module installed. This is included if you have RSAT installed or you are logged into a domain controller. You can verify the PowerShell module is installed with the following command:

    Terminal window
    Get-Module ActiveDirectory -ListAvailable

    Example output

    export ad users csv powershell

  2. Open PowerShell and run the following command. Update the <FilePath> to the location where you want to save the file.

    Terminal window
    Get-ADUser -filter * | Export-Csv -path <FilePath> -NoTypeInformation

    Example command

    export ad users csv powershell example

    When the command completes, you’ll have a CSV file at the path you specified

    CSV Example

    csv example of exported ad users

Method 2: Export AD Users to CSV with Entralyzer

Section titled “Method 2: Export AD Users to CSV with Entralyzer”

Entralyzer is a GUI based tool that makes it easy to export Active Directory users and other data from Active Directory and Microsoft 365.

  1. In the app, navigate to Reports > Active Directory > All Users

  2. Click the Columns button to add or remove users field to the report.

  3. Click the Export button and select your export format

    export ad users with entralyzer

With Entralyzer you can add filters to display and export specific users. For example, you can add a filter to display all users in a specific department.

Click the Add Filter button.

add filter

Next, specify the filter settings and click Apply.

filter settings

Now you will have a list of all users in a specific department that you can export.

filter example of ad users

Here are some additional powershell commands for exporting ad users to csv.

By default, the Get-ADUser command does not get all user fields. You need to include -Properties * to export all users fields.

Terminal window
Get-ADUser -filter * -Properties * | Export-Csv -path c:\it\AllUsers.csv -NoTypeInformation

Export a specific users by using -identity property and then the username.

Terminal window
Get-ADUser -identity robert.allen -Properties * | Export-Csv -path c:\it\SpecificUser.csv -NoTypeInformation
Terminal window
Get-ADUser -Filter * -Properties EmailAddress, Department, Title | Select-Object Name, SamAccountName, EmailAddress, Department, Title | Export-Csv -path "C:\it\UsersSpecificAttributes.csv" -NoTypeInformation

You need to set the SearchBase to the distinguishedName of the OU.

Terminal window
Get-ADUser -Filter * -SearchBase "OU=Accounting,OU=ADPRO Users,DC=ad,DC=activedirectorypro,DC=com" | Select-Object Name, SamAccountName | Export-Csv "C:\it\AccountingUsers.csv" -NoTypeInformation
Terminal window
Get-ADUser -Filter 'Enabled -eq $true' | Select-Object Name, SamAccountName | Export-Csv "C:\it\EnabledUsers.csv" -NoTypeInformation
Terminal window
Get-ADUser -Filter 'Enabled -eq $false' | Select-Object Name, SamAccountName | Export-Csv "C:\it\DisabledUsers.csv" -NoTypeInformation
Terminal window
Get-ADUser -Filter * -Properties LastLogonDate | Select-Object Name, SamAccountName, LastLogonDate | Export-Csv "C:\it\LastLogonDate.csv" -NoTypeInformation