How Can I Tell On What Date an Active Directory User Account Was Created?

Hey, Scripting Guy! Question

Hey, Scripting Guy! Is there any way to tell the date that an Active Directory user account was created?

— DD

SpacerHey, Scripting Guy! AnswerScript Center

Hey, DD. And thanks: between the work that piled up over the holidays, the upcoming Scripting Week 2, and a nasty flu bug that’s going around, it’s nice to have a question that can be answered with just two lines of code.

That’s right: two lines of code. To determine the date that a user account (or any other Active Directory object) was created, all you have to do is bind to the account and retrieve the value of the WhenCreated attribute:

Set objUser = GetObject(“LDAP://cn=ken myer, ou=Finance, dc=fabrikam, dc=com”)
Wscript.Echo objUser.WhenCreated

Cool, huh? The nice thing is that the value comes back as a real date and time, something on the order of 1/6/2005 8:10 AM. If you know anything about Active Directory, you know it isn’t always this easy to work with dates.

Incidentally, it’s just as easy to determine when an account was last modified. All you need to do is retrieve the value of the WhenChanged attribute:

Set objUser = GetObject(“LDAP://cn=ken myer, ou=Finance, dc=fabrikam, dc=com”)
Wscript.Echo objUser.WhenChanged

We know: it seems way too easy, doesn’t it? But, hey, enjoy it while you can; one of these days we’ll talk about the last logon and last logoff dates, and we can guarantee you that those won’t be quite as easy.

Comments (12)

  1. Anonymous says:

    For windows power shell run this for the user gbest

    get-aduser -identity gbest -properties whencreated

  2. Rajasekar says:

    How do i find all the users on particular date in Active directory?

  3. Marty says:

    What events cause the Last Modified date to change?

  4. Cecil says:

    Nice and to the point. Thanks, But, how can I find all the accounts that were created on a specific date?

  5. Zettai says:

    How can I tell "who" created a user in AD

  6. HI says:

    What is the command to find the computer objects from create date

  7. brad says:

    is it possible to determine when a user was added to a specific group

  8. moz says:

    Hi how can i export a list of users from perticular OU to text file which contain this created field

    for examples, a list of all users from "AUOU Test userblabla" to user.txt with this info

  9. DOS Vader says:

    why not just one line???

    Wscript.Echo GetObject("LDAP://cn=ken myer, ou=Finance, dc=fabrikam, dc=com").WhenCreated

    Wscript.Echo GetObject("LDAP://cn=ken myer, ou=Finance, dc=fabrikam, dc=com").WhenChanged

  10. Ramesh says:

    Try this Active Directory Manager for ad reporting .

  11. WowPowerShellIsSoEasy says:

    Ahh good old PowerShell:

    The term ‘GetObject’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Skip to main content