I to create the query that will export the following: Account FirstName LastName accountexpires the OU that the user resides in. So I will fetch Account expiry dates or account Never expire (those with no expiration date) for all AD users. its returning accountExpires attribute including that ridiculus large number
dsquery * -limit 0 "dc=contoso,dc=com" -filter "(&(objectCategory=Person)(objectClass=User)(!accountExpires=0)(!accountExpires=9223372036854775807)) " -attr sAMAccountname displayName accountexpires >> c:\temp\allusers2.txt
Output :
sAMAccountname displayName accountexpires
user1 user1 129706200000000000
user2 user2 129706200000000000
user3 user3 129706200000000000
user4 user4 131237046681910000
user5 user5 129706200000000000
user6 user6 129706200000000000
user7 user7 129706200000000000
user8 user8 131279544000000000