Alex said:
Guys, I am looking for an effective way to deal with some aging accounts. I
have users in my environment which do not always come in to the office. I am
trying to determine who is no longer using my network. therfore I am asking
two things: IS there a way to query the Active Directory for every computer
account in AD and its last logged on user and on what date?
My thought is that if I can sort all of my accounts in excel or something by
last loged on date, I can see how old the account really is an dwho logged
on to it. This way, I can start deleting accounts.
Any help, idea or thought would be apprecaited.
Hi,
I have two sample VBScript programs to help locate inactive user/computer
accounts. First, a program that documents all users in the domain and the
last time they logged on is linked on this page:
http://www.rlmueller.net/Last Logon.htm
Next, a sample program that documents all users and the last date their
password was set is linked on this page:
http://www.rlmueller.net/PwdLastChanged.htm
In both cases, the information can be imported into a spreadsheet for
analysis. If users are not necessarily required to change their password
periodically, you must use the lastLogon date.
The program to retrieve the pwdLastSet date queries just one Domain
Controller (DC), so it should be quite fast. The lastLogon attribute, is not
replicated, so the LastLogon program must query every DC in the domain for
the largest (latest) value for each user. Although the program is efficient
(it does not bind to each user object), it can still take awhile to run in a
large network, especially if there are slow links.
Both programs can be modified to retrieve the information for computer
objects instead of user objects. The required modification is given on the
pages linked. Since the default is for the system to reset computer account
passwords every 30 days, it is most efficient to use the PwdLastChanged
program for computer accounts, since that program only queries one DC.
It is not possible to query every client and determine who last logged into
it (and when). I believe the programs I linked above should give you what
you need. However, if you want to track who logs into which computers when,
you can use a logon script that logs this information to a shared log file.
I have used similar code for many years. I have a sample logon script
program that does this linked on this page:
http://www.rlmueller.net/Logon5.htm