|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Gustavo wrote:
> Hello guys, I need to find 2 scripts, that 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 s: -- Richard Mueller Microsoft MVP Scripting and ADSI Hilltop Lab - http://www.rlmueller.net -- |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
"Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in message news:uoApr0kJIHA.3636@TK2MSFTNGP03.phx.gbl... > Gustavo wrote: > >> Hello guys, I need to find 2 scripts, that 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 > If you domain is at Windows 2003 functional level, you can use the lastLogonTimeStamp attribute, which is replicated but is only updated during logon if the old value is at least 14 days in the past. To query for all users that have not logged in since 180 days ago, you can query for the users where lastLogonTimeStamp corresponds to a value smaller than the value that corresponds to this date. You can use this program to find the Integer8 (64-bit) value (in your time zone) that corresponds to any date: http://www.rlmueller.net/Programs/DateToInteger8.txt For example, in my time zone, the date May 13, 2007 (12:00 AM) corresponds to the Integer8 value: 128235096000000000 A query for all users whose lastLogonTimeStamp attribute corresponds to an older date would be: strFilter "(&(objectCategory=person)(objectClass)(lastLogonT imeStamp<=128235096000000000))" You can use ADO in a VBScript program to retrieve all of these users. If you domain is not at W2k3 functional level, the best solution is to simply retrieve the value of lastLogon for all users. -- Richard Mueller Microsoft MVP Scripting and ADSI Hilltop Lab - http://www.rlmueller.net -- |
|
![]() |
| Outils de la discussion | |
|
|