Setup: You have access to a domain member computer with Active Roles installed

Problem: You want to export users with details from specific OU to a CSV file

Solution: Open Powershell Active Roles console and run these commands:

$connection = connect-QADService -service 'fqdn.of.the.domain' -credential $cred # Enter proper credentials when prompted
$filedate = Get-Date -format yyyy.MM.dd
$file= "c:\path\to\file\result_" + $filedate + ".csv"

Get-QADUser -SearchRoot "OU=TESTOU,DC=domain" -IncludedProperties "c" -sizelimit 0 -enabled -connection $connection | select displayname,email,firstname,lastname,samaccountname,c | export-csv -Encoding UTF8 $file -NoTypeInformation

-sizelimit 0 will return all users. See for more details
-enabled return only enabled users. Remove to retrieve all users
-IncludedProperties is used to get a field from AD which is not in the list of fields supported by Get-QADUser

Tip 1: To find all available field for a user:

help Get-QADUser 

Tip 2: You can skip the credentials if you query the same domain.
Tip 3: You can avoid entering the credentials every time and store the password localy. See this article: Store a secure string (eg. a password) localy on disk in PowerShell.

Leave a Reply

Your email address will not be published. Required fields are marked *