← script library

Generate Active Directory User Reports

Active DirectoryJanuary 5, 2025

Keeping track of user information in Active Directory is essential for effective management and administration. In this post, we will provide a PowerShell script that generates a report of user details from Active Directory, including their account status, email addresses, and last logon dates. This script is useful for administrators looking to review user accounts quickly. At ServerEngine, we provide powerful server management solutions tailored to streamline IT operations.

powershell
Import-Module ActiveDirectory

function Generate-ADUserReport {
    param (
        [string]$reportPath = "C:\Path\To\Your\ADUserReport.csv"
    )
    $userDetails = Get-ADUser -Filter * -Properties DisplayName, EmailAddress, LastLogonDate, Enabled | 
                   Select-Object Name, DisplayName, EmailAddress, LastLogonDate, Enabled
    $userDetails | Export-Csv -Path $reportPath -NoTypeInformation
    Write-Host "User report has been generated at: $reportPath"
}

Generate-ADUserReport -reportPath "C:\Path\To\Your\ADUserReport.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.