Determine which computers are logged onto which Server 2016 AD server

My organization has two Server 2016 Active Directory domain controllers servers.

Where can I go to view which computers are logged into which domain controller?
IT GuyNetwork EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

William FulksSystems Analyst & WebmasterCommented:
This was asked on Microsoft's technet msg board, and the answer provides a couple of options you can look into. Both require you to download a little app of some kind, as the feature you want is not built into the server.
IvanSystem EngineerCommented:

I think that you can view that with a "set" command, that you run from cmd.
You will get "logonserver" information there.

Tom CieslikIT EngineerCommented:
If you have 2 DC in same Forest and same OU under same Domain name then users are not login to server but to Domain.
They're login to DOMAIN but register is their Primary Domain Controller and You can see this information by typing SET and check field = LOGONSERVER
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

IT GuyNetwork EngineerAuthor Commented:
I would like to be able to view which users are logged onto which server through running a program or command on the Server 2016 servers.

This way I can determine whether or not the logons are being properly load balanced between the two servers or if most of the users are logging onto one server instead of the other.

How can this be done?
Tom CieslikIT EngineerCommented:
Yes it's possible.

All you need to do is create a bat or CMD file and put this command into it

echo %username% - %logonserver% >> \\SERVER\SHARENAME\logon.txt

You need to put this file to Logon script in GPO and remember to add Write and Read and Modify permission for all users to share folder.

You can test this command from CMD from your computer to see if file will be created.
IT GuyNetwork EngineerAuthor Commented:
I need to view which servers all currently logged on users are logged onto. How can this be done?
Tom CieslikIT EngineerCommented:
Like I mentioned before you'll get what you want.
File will be filed out with all users log on with information about login name and server where user is connected to.
I've tested this command from 2 workstations and I've got

tom - \\MASTER
greg - \\MASTER1
IT GuyNetwork EngineerAuthor Commented:
I need to be able to launch a program or utility on one of the Server 2016 servers to see:

1. Which users are currently logged onto the domain

2. Which users are logged onto which server

I need to be able to see this without having to have a text file manually created from each workstation that is saved on the server.

What GUI or command line commands will allow this to be done?

Or if this isn't built into Windows what are some third party utilities that can be used for doing this?
Tom CieslikIT EngineerCommented:
3rd party software only and you have to pay for it
The made earlier, using user gpo with login/logout scripts with the login adds a record to a db
%username% %date% %time% %logonserver% %console% %computername%
Then the logout merely adds the date, time when the session added
With these added to a db, you can the have a query against this db
To pull all logged in users.
One way to clear login sessions that do not gave end session is to have a server shartup script that clears sessions from this database for users who were logged on this computer.

The script can be vbs powershell..

Users would have insert rights only for Windows based auth.....
Depending on your environment, SNMP, evntwin mapping logon/logout event with snmptrapd as the destination .......
Ajit SinghCommented:
PsLoggedOn tool can be used to find current logged on user to which computer.

There is another option, get the user profile information from the workstation itself and look for the LastAccessTime.  Here is a PowerShell script.

Also, there is a program called Psloggedon from Sysinternals. Which is free and scriptable, usage:

Usage: psloggedon [-l] [-x] [\\computername]
    or psloggedon [username]
-l     Show only local logons
-x     Don't show logon times

For more:

Also check this earlier thread i.e. list of users logged into domain, with computer name. You can also monitor user logons in a domain.

Hope this helps!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tom CieslikIT EngineerCommented:
Ajit Singh Psloggedon is not to good tool since you must run it on domain controller and then will show you all users who has access to share resources

Knowledgeable - please run command line I've presented on 2-3 workstations and you'll see effects.
Then create bat file and put it to logon script in GPO. You'll get list of all logged users with DC name on the list
Ajit SinghCommented:
Tom Cieslik - Thank you for letting me know.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 10

From novice to tech pro — start learning today.