← script library

Exporting Active Directory User Details to CSV

Active DirectoryJanuary 5, 2025

In this post, we will share a PowerShell script designed to export user details from Active Directory into a CSV file. This is particularly useful for administrators who need to generate reports or maintain records of user accounts. With just a few simple steps, you can gather essential information about your AD users. At ServerEngine, we are committed to providing tools that enhance your server management experience.

powershell
Import-Module ActiveDirectory

function Export-ADUsersToCSV {
    param (
        [string]$csvPath
    )
    $users = Get-ADUser -Filter * -Property DisplayName, EmailAddress, Enabled | Select-Object Name, DisplayName, EmailAddress, Enabled
    $users | Export-Csv -Path $csvPath -NoTypeInformation
    Write-Host "User details have been exported to $csvPath"
}

Export-ADUsersToCSV -csvPath "C:\Path\To\Your\ADUsers.csv"

Run it across your fleet

This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.

Ready when you are.

Try ServerEngine free for 7 days.