Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need a program/tool capable of periodically report the users logged in into the domain controlled by a Windows 2008 AD Server. A solution without periodically checking is also OK, because it's easy to run something scheduled. Also, I would prefer some command line tool, so I can write a script to wrap it's output and send it to another machine.

PS: I am only interested in built-in or free tools.

Thanks a lot.

share|improve this question
up vote 1 down vote accepted

Active Directory domains don't maintain 'session state', it's just a directory, you won't be able to retrieve a list of logged in users.

You can get the last login date of each user but would require a script to check every domain controller in your domain (script link).

share|improve this answer
I guess if you wanted to do something fancy with the event logs you can try this:… – BoyMars Nov 11 '10 at 10:08
another suggestion enumerates every user logged into every pc, but requires 'psloggedin' from SysInternals to be installed:… – BoyMars Nov 11 '10 at 10:31
This is an useful answer, and the link from the comment solves my problem, so I accept it. Thank you. – Patkos Csaba Nov 11 '10 at 11:51
my idea is to minimize network traffic for this. The purpose of the project is to communicate logged-in users (or login/logout events) to another machine which will take some actions based on the IP's and users logged in. I want to minimize the network traffic and query time, so a little tray application querying the logs on the AD seems to be the best solution, however I take notice of your comment because it may be useful in some situations. Thanks. – Patkos Csaba Nov 11 '10 at 11:55

You could, in a logon script, create a line that makes a file?

Something like?

net time >> \server\logonlogs\%username%.txt

Then in a logoff script del %username%.txt

share|improve this answer
I'm not advocating this method, but if someone decides to try this, remember to do net time >> \\server\logonlogs\%hostname%-%username%.log , since it is possible to log in on several computers at the same time. – ptman Nov 16 '10 at 13:50
Logon scripts should be added/modified on each client, right? I am interested to find out all the necessary information without intervention on the client machines, sorry if I wasn't clear enough in my question. I am not a Windows expert, so excuse me if my question is stupid. – Patkos Csaba Nov 17 '10 at 20:28
I would have thought as a domain, you'd already have a central logon scripts, and it would be adding to that. – Tubs Oct 12 '11 at 12:51

I have a logon/logoff script that modifies the description property of the computer object in AD with the username - date/time.

share|improve this answer

PowerShell Script

$searcher = New-Object DirectoryServices.DirectorySearcher([adsi]"") 
$searcher.filter = "(objectclass=user)" 
$users = $searcher.findall() 

Foreach($user in $users) 
 if($"lastLogon") -ne 0) 
   $a = [datetime]::FromFileTime([int64]::Parse($"lastLogon"))) 
   "$($`"name`")) $a" 
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.