Login | |
|
 |
RE: Active Directory Last logon time script help - 12/13/2006 4:16:54 PM
|
|
 |
|
| |
dm_4ever
Posts: 2641
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
If you wanted the last logon time you would need to modify your command text to retrieve the lastlogon and then use a function to change it into a date/time format. I currently can't try it to see if it works, but you would use something like this: NOTE: You will be getting the lastlogon time stamp for the user on the server you happen to query. You would need to create a new sub or seperate script to gather the lastlogon time stamp for a user on all servers to have a reliable lastlogon time. objCommand.CommandText = _ "<GC://ad.test.com>;(&(objectCategory=person)(objectClass=user)" _ &"(userPrincipalName=" &strSearchString& ")"_ &"(userAccountControl:1.2.840.113556.1.4.803:=2));userPrincipalName,lastlogon;subtree" Set objRecordSet = objCommand.Execute 'Wscript.Echo "record count =" & objRecordset.RecordCount If objRecordset.RecordCount > 0 Then ' if UPN & disabled mask were matched together during query 'Produce output based on results : modify from here on to produce different input for updated DB vbs script WScript.Echo "Last Logon Time: " & GetLast(objRecordSet("lastlogon").Value) objTextFile.WriteLine strUserNameForOutput &"," & strUserDomainForOutput ' UPN found as disabled End If Function getLast(last) getLast = ((last.HighPart * (2^32) + last.LowPart) / (60 * 10000000) / 1440) + #1/1/1601# End Function
_____________________________
dm_4ever My philosophy: K.I.S.S - Keep It Simple Stupid Read Me: http://www.visualbasicscript.com/m_24727/tm.htm Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Active Directory Last logon time script help - 12/14/2006 2:50:01 AM
|
|
 |
|
| |
ebgreen
Posts: 4970
Score: 31
Joined: 7/12/2005
Status: offline
|
Are you sure that it is? The file is opened for appending, so if there was data already there it would not be erased. Rename the file on your drive then run it again and see what you get.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Active Directory Last logon time script help - 12/14/2006 3:21:39 AM
|
|
 |
|
| |
dm_4ever
Posts: 2641
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
I don't see where you assing a value to strSearchString when querying AD.
< Message edited by dm_4ever -- 12/14/2006 3:29:31 AM >
_____________________________
dm_4ever My philosophy: K.I.S.S - Keep It Simple Stupid Read Me: http://www.visualbasicscript.com/m_24727/tm.htm Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Active Directory Last logon time script help - 12/14/2006 3:36:13 AM
|
|
 |
|
| |
ebgreen
Posts: 4970
Score: 31
Joined: 7/12/2005
Status: offline
|
So the record count really is 0 and you really aren't getting any information. You need to figure out why your query isn't returning anything.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Active Directory Last logon time script help - 12/14/2006 3:44:43 AM
|
|
 |
|
| |
ebgreen
Posts: 4970
Score: 31
Joined: 7/12/2005
Status: offline
|
quote:
cheers, no errors now, but the line WScript.Echo "Last Logon Time: " & GetLast(objRecordSet("lastlogon").Value) doesnt seem to produce anything. quote:
the wscript.echo's are coming out These two statements are contradictory. Are the echos producing output or not?
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
|
|