I have been working with RDS since before it was called RDS, and something that absolutely every single customer asks for is the ability to report on which users are connecting to which RDSH servers. Ideally, they would like to be able to see, historically, a list of people logging in, and sometimes even some data about when the user logged off the server as well. The only information I have ever found natively inside Windows that can help with this information gathering is the Windows Security Event Logs, but those are extremely messy to try and weed through to find what you are looking for. It's definitely not worth the hassle. So what's the solution here? The easiest way I have found to record login and logout information is to build and utilize some scripts that will run during every user logon and logoff. This is quite simple to do on each of your RDSH servers; let's give it a try together so you can have an idea of what I typically do, and then you can adjust from there based on your specific needs.
Here, we are going to build a couple of scripts on our RDS1 server, which is a Remote Desktop Session Host. Everything we will do is right on this Windows Server 2016 box.
Follow these steps to start recording information about user logins on your RDSH servers:
C:ReportingLogon.bat
Echo %date%,%time%,%username%,%computername% >> C:ReportingLogons.txt
C:WindowsSystem32grouppolicyuserscriptslogon
.
Alternatively, you could utilize two separate batch files, one for logons, and one for logoffs. I like this method because we can also split up the logging into multiple smaller text files, one for each username. Then we can see very quickly all the times that each username logged in and logged out. Here is an example of how to accomplish that:
Echo LOGON,%date%,%time%,%username%,%computername% >> "C:Reporting\%username%.log"
.Echo LOGOFF,%date%,%time%,%username%,%computername% >> "C:Reporting\%username%.log"
.C:WindowsSystem32grouppolicyuserscriptslogon
.C:WindowsSystem32grouppolicyuserscriptslogoff
.C:Reporting
folder. Now we have multiple text files listed here, one for each username. Inside each text file we can see timestamps for both logons and logoffs that were performed by that user. It's pretty neat data collection for how simple those scripts are!
We can utilize some very simple logon and logoff scripts on RDSH servers in order to generate reporting information about who is logging in, where they are logging in, and at what times they are coming and leaving. Incorporating these reporting scripts onto each of your RDSH servers and then having them all report to a central location can greatly improve your ability to generate user accounting information. This is a common question among those utilizing RDS, and hopefully you can take this information and build on top of it further to gather whatever info is important to your organization.
3.149.231.97