Link to home
Create AccountLog in
Avatar of nav2567
nav2567Flag for United States of America

asked on

GET-ADUSER command result file has missing users.

Hello,

I am running the below command to list our domain users but there are accounts which are missing in the result file.

Get-Aduser -Filter  -Properties * |Select samAccountName,name,displayName,department,distinguishedName,givenName,mail,@{n='PasswordLastSet';e={[DateTime]::FromFileTime($_.PasswordLastSet)}},@{n='LastLogon';e={[DateTime]::FromFileTime($_.LastLogon)}},@{n='LastLogonTimestamp';e={[DateTime]::FromFileTime($_.LastLogonTimestamp)}} |Export-CSV "C:\mydomainusers.csv" -NoTypeInformation -Encoding UTF8

Is there a limitation in displaying the number of users?  

Please advise.  

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
I've seen that tossed around before (the 1000 result limit), but I don't know where it came from, and I've never observed that to be the case.  On a lab machine I just returned more than 35,000 users without using the -ResultSetSize parameter.
PS C:\Users\Administrator.TEMPTEST> (get-aduser -Filter *).count
35037

Open in new window


Where are you running your Get-ADUser command?
If running on a DC, I've seen partial results if not running from an elevated prompt, and also when querying the same DC you're running on.  You could try specifying another DC with the -Server parameter.

If your query is taking a long time, it's possible to run into some timeouts.
I would also narrow your -properties * to  -properties only the attributes you want to select separated with a ,

-properties mail,userprincipalname,etc, etc.

This will speed it up if you are query a large set of users.