Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Creation date of users in AD

Posted on 2007-07-22
Medium Priority
Last Modified: 2012-08-14
Does any one know how i can export a list of users from AD including the creation date and the last time the password was changed?
Question by:tollair
  • 2
  • 2
LVL 19

Accepted Solution

William Elliott earned 200 total points
ID: 19544677
Purpose: To create a CSV listing of all users in Active Directory, listing whether the account is disabled or enabled, provide both first and last name for sorting, and list the last time the password on the account was reset, allowing for the flagging of accounts that need to be investigated and/or disabled

this will get specific user object details including creations time. you can incorporate the two if needed

Set objUser = GetObject _
strWhenCreated = objUser.Get("whenCreated")
strWhenChanged = objUser.Get("whenChanged")
Set objUSNChanged = objUser.Get("uSNChanged")
dblUSNChanged = _
    Abs(objUSNChanged.HighPart * 2^32 + objUSNChanged.LowPart)
Set objUSNCreated = objUser.Get("uSNCreated")
dblUSNCreated = _
    Abs(objUSNCreated.HighPart * 2^32 + objUSNCreated.LowPart)
objUser.GetInfoEx Array("canonicalName"), 0
arrCanonicalName = objUser.GetEx("canonicalName")
WScript.echo "Canonical Name of object:"
For Each strValue in arrCanonicalName
    WScript.Echo vbTab & strValue
WScript.Echo "Object class: " & objUser.Class
WScript.echo "When Created: " & strWhenCreated & " (Created - GMT)"
WScript.echo "When Changed: " & strWhenChanged & " (Modified - GMT)"
WScript.Echo "USN Changed: " & dblUSNChanged & " (USN Current)"
WScript.Echo "USN Created: " & dblUSNCreated & " (USN Original)"

Author Comment

ID: 19552816
thanks for that, are you able to add in code for OU for each user as well?

Author Comment

ID: 19552845
Just one more thing, the output doesn't show the creation date.
LVL 19

Expert Comment

by:William Elliott
ID: 19561041
one question are you familiar with vbs and how to modify it?  if so you can pull the code from the first script to search the entire AD infrastructure for the second code.. or combine them into one.

scriptinganswers.com may have one available already.

the real question is why do you need this information?will it be used with other information, i may have a script that does what you need this to do.

Expert Comment

ID: 21392511
Forced accept.

EE Admin

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Uncontrolled local administrators groups within any organization pose a huge security risk. Because these groups are locally managed it becomes difficult to audit and maintain them.
Scripts are great for performing batch jobs against users, however sometimes the GUI is all you need.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question