Log/Save domain users login/logout time on Windows Server 2008 R2
Solution 1
The easiest thing to do - that I would do to collect the most potentially relevant information - is to create batch scripts with the following lines (and place the batch scripts in Group Policy logon and logoff scripts - with .cmd extensions)
for logon:
echo %username% logged on from %computername% on %date% at %time%>>\server\share\logon.log
and for logout:
echo %username% logged off from %computername% on %date% at %time%>>\server\share\logoff.log
(You can use the same file and don't need to separate them, but for convenience, I split them into two files).
The above should append a line to the files logon.log or logoff.log (as appropriate) with the user's account name, the computer that the user logged in from, and the date and time.
By opening the file in excel and using the text-to-columns feature, you can easily create sortable reports. (And you can leave off the text simplifying the logged data into something like echo %username%,%computername%,%date%,%time%)
Solution 2
If you're using BAT, then just use time /t
. Easy as cake.
Related videos on Youtube
Luigi Siri
Web Developer at a Hardware store... somewhere... #SOreadytohelp
Updated on September 18, 2022Comments
-
Luigi Siri over 1 year
My idea is to make log-in and log-out scripts to capture the login/logout time and save it to a file (or into a Database). I have no idea how to capture the time.
-
Luigi Siri about 12 yearsI found this script to capture the local machine last logon.
-
-
Luigi Siri about 12 yearsThanks. But, Which other way can i use for that goal? (without the scripts)
-
joeqwerty about 12 yearsLuigi, in your question you clearly state that you want to achieve this via scripts.
-
Luigi Siri about 12 yearsYes, and i continue with the idea. But if there is a more efficient way to do it, I'll do it.