如何在PowerShell中查找用户terminal会话

我会请求一些帮助findterminal会话(如思杰)的用户。 我在这个论坛上已经经历了“terminal会议”上提出的大部分问题。 不幸的是,没有什么帮助我:(

我尝试searchget-PSterminalsessions ( http://psterminalservices.codeplex.com ),但按照给定的步骤执行后,此模块不加载。 我在Win 7以及2008 R2上都尝试过。

当我尝试使用invoke-expressions -command "Quser xyz"它不会返回任何内容。

试试从powershellcommunity.org脚本库:

 Function Get-ComputerSession { <# .SYNOPSIS Retrieves all user sessions from local or remote server/s .DESCRIPTION Retrieves all user sessions from local or remote server/s. Requires query.exe in order to run properly. .PARAMETER computer Name of computer/s to run session query against. .NOTES Name: Get-ComputerSession Author: Boe Prox DateCreated: 01Nov2010 .LINK https://boeprox.wordpress.org .EXAMPLE Get-ComputerSessions -computer "server1" Description ----------- This command will query all current user sessions on 'server1'. #> [cmdletbinding( DefaultParameterSetName = 'session', ConfirmImpact = 'low' )] Param( [Parameter( Mandatory = $True, Position = 0, ValueFromPipeline = $True)] [string[]]$computer ) Begin { $report = @() } Process { ForEach($c in $computer) { # Parse 'query session' and store in $sessions: $sessions = query session /server:$c 1..($sessions.count -1) | % { $temp = "" | Select Computer,SessionName, Username, Id, State, Type, Device $temp.Computer = $c $temp.SessionName = $sessions[$_].Substring(1,18).Trim() $temp.Username = $sessions[$_].Substring(19,20).Trim() $temp.Id = $sessions[$_].Substring(39,9).Trim() $temp.State = $sessions[$_].Substring(48,8).Trim() $temp.Type = $sessions[$_].Substring(56,12).Trim() $temp.Device = $sessions[$_].Substring(68).Trim() $report += $temp } } } End { $report } }