如何识别通过远程桌面连接到 Windows 服务器的用户

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/562922/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 12:00:07  来源:igfitidea点击:

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

windowsloggingscriptingremote-desktopevent-log

提问by Julien Nephtali

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 parserand wanted to share it to the stack overflow community.

我终于找到了一个使用Microsoft 日志解析器的解决方案,并希望将其分享给堆栈溢出社区。

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.

它是在机器上运行的批处理文件,因此用户可以识别最后使用机器的用户,并轻松地通过 IM 向他们询问机器是否空闲。

Is there a better solution to do this?

有没有更好的解决方案来做到这一点?

回答by Oskar Duveborn

Use the built-incommand 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).

使用内置命令qwinsta(Query Win Station) 确定哪些会话(包括控制台)处于活动状态或非活动状态(断开连接),然后根据给定的信息采取行动(信任 krusty.ar btw 已将其链接)。

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

如果你觉得人们在滥用有问题的机器,请参考rwinsta以消除他们的会话......

回答by Julien Nephtali

You will need to install the Microsoft Log Parser

您将需要安装Microsoft Log Parser

Then create the following 2 files

然后创建以下2个文件

TSLoginsDetails.sql

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

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.

现在,通过将此批处理文件放在桌面上,用户可以看到最后登录的人是谁,并通过 IM 与他们联系以验证他们是否已登录。

回答by MrChrister

How about posting the information from the log file to the website that tells who is currently using the machine as well.

将日志文件中的信息发布到网站上,告诉谁当前正在使用该机器,如何?

  1. Check and notify when they log in.
  2. Updated the "who is using the machine" page you made prior.
  3. Run a AT job that checks every couple of hours who is on it.
  1. 检查并在他们登录时通知。
  2. 更新了您之前制作的“谁在使用机器”页面。
  3. 运行一个 AT 作业,每隔几个小时检查一下谁在做。

回答by Patrick Cuff

Totally out of the box:

完全开箱即用:

You can install the Software Testing Automation Framework (STAF)on your servers and desktops to manage your tests. It's written in Java, so you can use it on Windows and Unix/Linux desktops and servers.

您可以在服务器和台式机上安装软件测试自动化框架 (STAF)来管理测试。它是用 Java 编写的,因此您可以在 Windows 和 Unix/Linux 桌面和服务器上使用它。

Using STAF, you can create a resource pool of test servers on which you conduct tests, then write STAX jobs (STAX is a STAF execution framework) to conduct the tests. The job can grab the first available server from the resource pool, run the test, monitor the test status, log results, notify the submitter, then release the server back into the pool when done. If you have multiple people submitting jobs for tests, STAF will manage the queue of requests and satisfy them as they came in. Users can either monitor the job from their desktop, or you can set up email alerts to notify them when the test is complete.

使用 STAF,您可以创建一个测试服务器资源池,在其上进行测试,然后编写 STAX 作业(STAX 是 STAF 执行框架)来进行测试。该作业可以从资源池中获取第一个可用的服务器,运行测试,监控测试状态,记录结果,通知提交者,然后在完成后将服务器释放回资源池中。如果有多人提交测试作业,STAF 将管理请求队列并在他们进来时满足他们。用户可以从他们的桌面监控作业,或者您可以设置电子邮件警报以在测试完成时通知他们.

回答by krusty.ar

I'm not sure if I understand you, but there are a set of command line tools to deal with terminal server sessions, and there's also a Windows APIto do the same if you need to do this from a program.

我不确定我是否理解您的意思,但是有一组命令行工具可以处理终端服务器会话,如果您需要从程序中执行此操作,还有一个Windows API可以执行相同的操作。

回答by Joel Coehoorn

Since it sounds like you're a microsoft shop, you can set up the machines as resources in outlook/exchange and reserve them that way.

由于听起来您是一家微软商店,您可以将机器设置为 Outlook/Exchange 中的资源并以这种方式保留它们。