Re: List users that last logon was 180 days ago

Tech-Archive recommends: Fix windows errors by optimizing your registry



Gustavo wrote:

Hello guys, I need to find 2 scripts, that help me to list all users in a
domain, where the users never have done logon, and another script that
list
the users that theis last logon was 180 days ago

I have two example VBScript programs that retrieve the last logon dates for
all users in the domain linked here:

http://www.rlmueller.net/Last%20Logon.htm

Because the lastLogon attribute is not replicated, the program lastLogon.vbs
must query ever DC in the domain to find the largest (latest) value for each
user. This should give you what you want. The second program,
LastLogonTimeStamp.vbs requires Windows 2003 functional level and uses the
new lastLogonTimeStamp attribute. In both cases the data "1/1/1601" means
never.

Using LastLogon.vbs to restrict the output to users that have never logged
on, the best method would be to check for this in the last loop where the
results are output. The existing loop is:

' Output latest lastLogon date for each user.
For Each strUser In objList.Keys
Wscript.Echo strUser & " ; " & objList.Item(strUser)
Next

This could be modified as follows:

' Output latest lastLogon date for each user.
For Each strUser In objList.Keys
If (objList.Item(strUser) = #1/1/1601#) Then
Wscript.Echo strUser & " ; " & objList.Item(strUser)
End If
Next

Using LastLogonTimeStamp.vbs, you could change the following:

' Display values for the user.
If (dtmDate = #1/1/1601#) Then
Wscript.Echo strDN & ";Never"
Else
Wscript.Echo strDN & ";" & dtmDate
End If

To this:

' Display values for the user.
If (dtmDate = #1/1/1601#) Then
Wscript.Echo strDN & ";Never"
End If

I hope this helps:

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--


.



Relevant Pages

  • Re: Users last logon info from logon script
    ... I put this line in the users logon script: ... If I run the script manually, it shows the last logon time. ... I guess it is because Windows update the lastlogon attribute once a user ... Then, for each Domain Controller, ADO is used to search the ...
    (microsoft.public.security)
  • Re: Log file!
    ... Here is an example VBScript program to retrieve the lastLogon values for all ... logon and logoff info, you can assign Logon and Logoff scripts using Group ... This script appends a line to a log file in a shared location. ...
    (microsoft.public.windows.server.active_directory)
  • Re: "Last logon time" & "Last time the account was authenticated b
    ... I do have a script that extracts last logon details ... the updated Last logon time. ... corresponds to the value of the lastLogon attribute. ...
    (microsoft.public.windows.server.active_directory)
  • Re: Count Domain User Logon
    ... Richard's script gives you the lastLogon date for all users in the domain. ... interactive logon and kerb ticket, ...
    (microsoft.public.windows.server.active_directory)
  • Re: slow logon
    ... in the logon time have been reduced so far. ... update the time for the clients that talk to the dc as the logon server. ... start up script in AD to apply updates to the clients machines which is ...
    (microsoft.public.windows.server.active_directory)