December 28, 2012 at 10:17 pm
Hi All,
Our servers are open to quite a few people. Unfortunately we cannot restrict the number of users on the Box at the same time. But, what I see is the people are logging in and not logging off. They are just disconnecting from the server.
Can I please have script that gies me a list of people who are logged on the box so that i can shoot an email to the team showing who is been lazy cat.
I know I can see who is logged in at TSADMIN.MSC I could possibly get the user name, time of login that would be awesome.
December 29, 2012 at 5:19 am
I think this is more of a system admin question than a SQL Server question. You can setup your RDP endpoint to end disconnected sessions after a certain amount of time.
If you must do this from a command line I would look at using PowerShell. Here is a module that seems to work well although I only tested it on my local machine and I am not sure it will give you all the properties of a session you need to make a decision in your environment:
Terminal Services PowerShell Module
- Go to the Downloads page and get the zip file.
- Extract the PSTerminalServices folder into C:\Windows\System32\WindowsPowerShell\v1.0\Modules\, i.e. you should have a new folder C:\Windows\System32\WindowsPowerShell\v1.0\Modules\PSTerminalServices containing PSTerminalServices.psd1 and PSTerminalServices.psm1 as well as folders Bin, en-US and Format.
- At a new PowerShell prompt run Import-Module PSTerminalServices to bring the module into your session.
Now you can run things like:
Get-TSSession -ComputerName someComputer -State Disconnected
to see all disconnected sessions for a particular server.
Running this will will explain the cmdlet's capabilities in detail including all available statuses you can check for:
help Get-TSSession -Detailed
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
January 3, 2013 at 1:29 am
Great!!! this thing works. Now all I want is below 2 things. If its possible..
1) Get the Login time as of the column (If possible. Not necessary though)
2) have the result set that I see in the powershell window in a form of email.
Please suggest..
January 4, 2013 at 11:54 am
Get-TSCurrentSession | Get-Member
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply