AD-Export with Get-QADUser is too slow

Sometimes I need to export more than 5000 Active Directory Users for analysis to CSV. Therefore I use an existing PowerShell script which uses the cmdlet Get-QADUser.

Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue
Connect-QADService -service '' 

Get-QADUser -SizeLimit 0 -DontUseDefaultIncludedProperties 
	-IncludedProperties name, displayname, samaccountname, l, company |
	select name, displayname, samaccountname, l, company  |
	export-csv "c:\\temp\\export.csv" –encoding "unicode" -NoTypeInformation

The code above runs for about ten minutes before completion. I excessively searched for an alternative and found the .NET class System.DirectoryServices.DirectorySearcher. With the following code being executed it takes about 10 seconds to export all AD-Users to a CSV file.

$domain = "LDAP://"
$outfile = "c:\\temp\\export.csv"
$properties = "company" ,"sAMAccountName", "displayName", "name", 
	"mail", "l", "homeDirectory", "lastLogon", "lastLogonTimestamp"
$properties = $properties | % { $_.ToLower() }

Write-Host "Searching AD..."

$dn = New-Object System.DirectoryServices.DirectoryEntry($domain)
$ds = New-Object System.DirectoryServices.DirectorySearcher($dn)
$ds.Filter = '(&(objectCategory=person)(objectClass=user))'
$list = $ds.FindAll()

Write-Host "Exporting" $list.Count "Records..."

# The AD results are converted to an array of hashtables.
$table = @()
foreach($item in $list) {
    $hash = @{}
    foreach($name in $properties){
            $hash.$name = $item.Properties[$name][0]
            $hash.$name = $null
    $table += New-Object PSObject -Property $hash
$table | Export-Csv $outfile –encoding "unicode" -NoTypeInformation

Write-Host "Done."

I think the problem with the first code is the pipe linkage. The Get-QADUser cmdlet is not executed until output should be generated (indicated by Export-Csv). On execution every AD-User is written to the CSV one-by-one. The second script gets all Users and then writes them all-at-once.