Q
Problem solve Get help with specific problems with your technologies, process and projects.

Finding the creation date of objects

I want to make a script where the filter is the creation date of the User.

Where can I find the creation date of an object, like Users? I want to make a script where the filter is the creation date of the User. I hope you can help me.
Here is a snippet of a VBScript:
strContainer = "users"
strName = "phinsberg"


dim strname
On Error Resume Next
'***********************************************
'* Connect to an object *
'***********************************************
Set objRootDSE = GetObject("LDAP://rootDSE")
If strContainer = "" Then
 Set objItem = GetObject("LDAP://" & _
 objRootDSE.Get("defaultNamingContext"))
Else
 Set objItem = GetObject("LDAP://cn=" & strName & "," & strContainer & "," & _
 objRootDSE.Get("defaultNamingContext"))
End If
'***********************************************
'* End connect to an object *
'***********************************************
WScript.Echo VbCrLf & "** General Properties Page**"
WScript.Echo "** (Single-Valued Attributes) **"
strname = objItem.Get("name")
WScript.Echo "name: " & strname

WScript.Echo VbCrLf & "** Object Properties Page**"
WScript.Echo "** (Single-Valued Attributes) **"
strwhenCreated = str(objItem.Get("whencreated"))
WScript.Echo "whenCreated: " & strwhenCreated
strwhenChanged = objItem.Get("whenChanged")
WScript.Echo "whenChanged: " & strwhenChanged
The rather odd thing is the unusual inconsistency with actually retrieving the dates at times. This script is looking for the OU=users and the object=phinsberg. You can use the same process iteratively to retrieve multiple users. Like I said though, the problem is the seemingly inconsistent behavior of retrieving the date attributes. You can view the information on a user account from the ADSIEdit MMC, but the ADSI script engine sometimes has a problem.

Additional Expert Help:
Be sure to check our Answer FAQ for more expert advice.
For faster answers, visit ITKnowledge Exchange.

Dig Deeper on Windows administration tools

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchServerVirtualization

SearchCloudComputing

SearchSQLServer

SearchEnterpriseDesktop

SearchVirtualDesktop

Close