{"id":70713,"date":"2005-01-06T10:09:00","date_gmt":"2005-01-06T10:09:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2005\/01\/06\/how-can-i-tell-on-what-date-an-active-directory-user-account-was-created\/"},"modified":"2005-01-06T10:09:00","modified_gmt":"2005-01-06T10:09:00","slug":"how-can-i-tell-on-what-date-an-active-directory-user-account-was-created","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-tell-on-what-date-an-active-directory-user-account-was-created\/","title":{"rendered":"How Can I Tell On What Date an Active Directory User Account Was Created?"},"content":{"rendered":"<p><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\"> \n<P>Hey, Scripting Guy! Is there any way to tell the date that an Active Directory user account was created?<BR><BR>&#8212; DD<\/P><IMG border=\"0\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" height=\"5\"><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\"><A href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><IMG class=\"farGraphic\" title=\"Script Center\" border=\"0\" alt=\"Script Center\" align=\"right\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" height=\"288\"><\/A> \n<P>Hey, DD. And thanks: between the work that piled up over the holidays, the upcoming Scripting Week 2, and a nasty flu bug that\u2019s going around, it\u2019s nice to have a question that can be answered with just two lines of code.<\/P>\n<P>That\u2019s 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:<\/P><PRE class=\"codeSample\">Set objUser = GetObject(&#8220;LDAP:\/\/cn=ken myer, ou=Finance, dc=fabrikam, dc=com&#8221;)\nWscript.Echo objUser.WhenCreated\n<\/PRE>\n<P>Cool, huh? The nice thing is that the value comes back as a real date and time, something on the order of <B>1\/6\/2005 8:10 AM<\/B>. If you know anything about Active Directory, you know it isn\u2019t always this easy to work with dates.<\/P>\n<P>Incidentally, it\u2019s just as easy to determine when an account was last modified. All you need to do is retrieve the value of the WhenChanged attribute:<\/P><PRE class=\"codeSample\">Set objUser = GetObject(&#8220;LDAP:\/\/cn=ken myer, ou=Finance, dc=fabrikam, dc=com&#8221;)\nWscript.Echo objUser.WhenChanged\n<\/PRE>\n<P>We know: it seems way too easy, doesn\u2019t it? But, hey, enjoy it while you can; one of these days we\u2019ll talk about the last logon and last logoff dates, and we can guarantee you that those won\u2019t be quite as easy.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! Is there any way to tell the date that an Active Directory user account was created?&#8212; DD Hey, DD. And thanks: between the work that piled up over the holidays, the upcoming Scripting Week 2, and a nasty flu bug that\u2019s going around, it\u2019s nice to have a question that can be [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[7,3,20,5],"class_list":["post-70713","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-active-directory","tag-scripting-guy","tag-user-accounts","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! Is there any way to tell the date that an Active Directory user account was created?&#8212; DD Hey, DD. And thanks: between the work that piled up over the holidays, the upcoming Scripting Week 2, and a nasty flu bug that\u2019s going around, it\u2019s nice to have a question that can be [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/70713","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=70713"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/70713\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=70713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=70713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=70713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}