I'm running a query to pull data from AD. I have a 2 line script to get the data. The first line takes 4 or 5 minutes to complete. It returns around 200,000 users. The second line takes about 20 hours to complete.
$allEnabled = Get-adUser -f { (userAccountControl -eq 512) -and (Enabled -eq $true) } -properties employeeID, emailaddress, GivenName, SurName
$allEnabled | ft employeeID, emailaddress, GivenName, SurName | out-file d:\temp\output.txt
I've tried writing the output one line at a time, and I've tried stuffing it in an array but I can't find a way to write the data any quicker. I've run it from a beefy server with ample resources so CPU and memory are not constrained.