Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to identify users which are connected to a windows server via remote desktop

At my workplace, we have lab machines that we use to do our testing.

The standard procedure to reserve a machine for testing was to walk around the office to make sure that no one was using the machine.

This is highly inefficient and time consuming.

At first, I set up a web page where people could reserve the lab machine but nobody was keeping the page updated so that turned up to be useless.

I finally found a solution using Microsoft log parser and wanted to share it to the stack overflow community.

It is a batch file that runs on the machine so the user can identify the last users that use the machine and easily IM them to ask if the machine is free.

Is there a better solution to do this?

like image 753
Julien Nephtali Avatar asked Feb 18 '09 21:02

Julien Nephtali


2 Answers

Use the built-in command qwinsta (Query Win Station) to figure out what sessions (including console) are active or inactive (disconnected) and then act on the given information (creds to krusty.ar btw for linking this already).

If you feel people are abusing the machine in question, refer to rwinsta to nuke their sessions into oblivion...

like image 175
Oskar Duveborn Avatar answered Nov 15 '22 07:11

Oskar Duveborn


You will need to install the Microsoft Log Parser

Then create the following 2 files

TSLoginsDetails.sql

SELECT 
      timegenerated, 
      EXTRACT_TOKEN(Strings,1,'|') AS Domain, 
      EXTRACT_TOKEN(Strings,0,'|') AS User, 
      EXTRACT_TOKEN(Strings,3,'|') AS SessionName,
      EXTRACT_TOKEN(Strings,4,'|') AS ClientName,
      EXTRACT_TOKEN(Strings,5,'|') AS ClientAddress,
      EventID
FROM Security 
WHERE EventID=682 
ORDER BY timegenerated DESC

TSLogins.bat

echo off
cls
c:
cd "c:\Program Files\Log Parser 2.2\"
logparser.exe file:TSLoginsDetails.sql -o:DATAGRID

Now by placing this batch file on the desktop, the user can see who were the last people to login and contact them by IM to verify if they are done.

like image 24
Julien Nephtali Avatar answered Nov 15 '22 07:11

Julien Nephtali