用于查看当前登录用户(域和机器)+状态(活动、空闲、离开)的 Powershell 脚本 [英] Powershell script to see currently logged in users (domain and machine) + status (active, idle, away)

查看:71
本文介绍了用于查看当前登录用户(域和机器)+状态(活动、空闲、离开)的 Powershell 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个简单的命令来查看服务器上的登录用户.我知道这个:

I am searching for a simple command to see logged on users on server. I know this one :

Get-WmiObject -Class win32_computersystem

但这不会为我提供我需要的信息.它返回:领域制造商模型名称(机器名称)主要所有者名称总物理内存

but this will not provide me the info I need. It returns : domain Manufactureer Model Name (Machine name) PrimaryOwnerName TotalPhysicalMemory

我在 Windows 2012 服务器上运行 Powershell 3.0.

I run Powershell 3.0 on a Windows 2012 server.

还有

Get-WmiObject Win32_LoggedOnUser -ComputerName $Computer | Select Antecedent -Unique

没有给我我需要的确切答案.我也很想看看空闲时间,或者他们是否活跃或离开.

gives me not the exact answers I need. I would love to see as well the idle time, or if they are active or away.

推荐答案

在寻找相同的解决方案时,我在 stackoverflow 中的一个不同问题下找到了我需要的内容:Powershell-log-off-remote-session.下面一行将返回登录用户列表.

In search of this same solution, I found what I needed under a different question in stackoverflow: Powershell-log-off-remote-session. The below one line will return a list of logged on users.

query user /server:$SERVER

这篇关于用于查看当前登录用户(域和机器)+状态(活动、空闲、离开)的 Powershell 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆