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.