Sunday, July 24, 2011

Active Directory Users logon and logoff report

Active Directory Users logon and logoff report


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.
c:\windows> 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. 



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.

3 comments:

  1. Thank you! An excellent and simple solution!

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Nice blog post, thanks for the helpful information related to generate report on active directory user logon and logoff details. I found good information from https://www.netwrix.com/logon_auditing.html that helps to generate automate report basis on AD user log on and log off details and manage them and move inactive accounts to another OU and shows the list of inactive users, disabled users, locked out users, inactive and disabled computers.

    ReplyDelete