0

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 
Arbelac
  • 1,698
  • 6
  • 37
  • 90
  • This value represents the number of 100-nanosecond intervals since January 1, 1601 (UTC). A value of 0 or 0x7FFFFFFFFFFFFFFF (9223372036854775807) indicates that the account never expires. See https://msdn.microsoft.com/en-us/library/ms675098(v=vs.85).aspx. – oldovets Oct 05 '16 at 13:20
  • @DmitryAlexandrov Thanks for your answer. Could you please clarify me with sample code? – Arbelac Oct 05 '16 at 17:29
  • Powershell example: https://social.technet.microsoft.com/Forums/windowsserver/en-US/8313f58a-b763-43bf-ab7b-b57438b26f1d/convert-the-ad-property-accountexpires-to-readable-date-time?forum=winserverpowershell. If you like to use command line utils you can look at AdFind utility – oldovets Oct 05 '16 at 18:55

0 Answers0