Thursday, February 17, 2011

Active Directory Users logon and logoff report - Solved

For Active directory user’s logon and logoff reports, it needs the third party tools. But in windows have that capability. Most of the IT professionals are not learned DOS commands in-depth. The DOS command does this process. All are heard about echo command; this command can do the report for our need.

For Example:-
Go to your command prompt, type the below following command.
Echo %username% is logged on to %computername% at %time% 

The above command gives the output like his name, computer name and login time. Our need is to generate report for all users, so here we need to create a logon batch file script. Before creating the batch file, we need to create a central repository for storing the log files. Create a hidden share for logon, logoff and give the permission to users.Batch file for logon script Copy the below code edit the systemname, sharename and paste into the notepad, then save it as batch (.bat) file.
Echo %username% is logged on to %computername% at %time% >> \\systemname\Sharename$\%username%_logon.csv
The batch file needs to put on the logon script in the group policy. All log files will be save in separate for each users. Please find the below image, that was the output.

For Log off report use the below command for batch file
Echo %username% is logged on to %computername% at %time% >> \\systemname\Sharename$\%username%_logoff.csv
Copy the above code and create a batch file, apply on the logoff script in the group policy.


Shackks said...

Very good idea. But what happens if the workstation are not configured to login to the domain? Will that be able to track the user's activity on the share folder?

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...

Thank you.. very Useful.


lfcuadmin said...

I tried this tonight, but when I open in Excel 2010, the CSV file does not parse to different cells. It is all viewable in one cell.

Anonymous said...

How would you get this info for the past week?

Immu said...

we use student registration number (e.g. 1234) to be the account name/username of students.

now we use
echo %username% logged into %computername% at %time%
to record their login information in text file.
the result is like this:
"1234 logged into computer-1 at 13:20"

Is there a way that I can also record the Display name of the user and the name of Group/OU that he belongs to?

my email is