AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 738619
Accepted
Kjensen
Kjensen
Asked: 2015-11-25 04:46:40 +0800 CST2015-11-25 04:46:40 +0800 CST 2015-11-25 04:46:40 +0800 CST

列出用户使用远程桌面连接到的所有服务器

  • 772

有没有办法列出所有服务器,给定用户登录到整个活动目录?

就像是...:

QueryRdpConnections -user BobAdmin

结果...:

Server         
----------------
Web001
Web002
Web003
SQL004
SQL007
active-directory
  • 1 1 个回答
  • 7157 Views

1 个回答

  • Voted
  1. Best Answer
    pungk
    2015-11-25T06:55:53+08:002015-11-25T06:55:53+08:00

    您可以在 powershell 中使用 qwinsta:

    QUERY SESSION [sessionname | username | sessionid]
                  [/SERVER:servername] [/MODE] [/FLOW] [/CONNECT] [/COUNTER] [/VM]
    
      sessionname         Identifies the session named sessionname.
      username            Identifies the session with user username.
      sessionid           Identifies the session with ID sessionid.
      /SERVER:servername  The server to be queried (default is current).
      /MODE               Display current line settings.
      /FLOW               Display current flow control settings.
      /CONNECT            Display current connect settings.
      /COUNTER            Display current Remote Desktop Services counters information.
      /VM                 Display information about sessions within virtual machines.
    

    快速搜索可以在 technet 上找到这篇文章。

    我正在使用脚本的以下部分来查询所有活动服务器并查找远程登录的用户:

    function QueryRdpConnections {
    $ErrorActionPreference= 'silentlycontinue'
    # Import the Active Directory module for the Get-ADComputer CmdLet 
    Import-Module ActiveDirectory 
    
    #Query Active Directory for computers running a Server operating system 
    $Servers = Get-ADComputer -Filter {OperatingSystem -like "*server*" -and Enabled -eq 'true'} 
    
    ForEach ($Server in $Servers) { 
        $ServerName = $Server.Name 
    
    
    # Run the qwinsta.exe and parse the output 
    $queryResults = (qwinsta /SERVER:$ServerName | foreach { (($_.trim() -replace "\s+",","))} | ConvertFrom-Csv)
    
    # Pull the session information from each instance 
    ForEach ($queryResult in $queryResults) { 
    $RDPUser = $queryResult.USERNAME
    $sessionType = $queryResult.SESSIONNAME 
    
    # We only want to display where a "person" is logged in. Otherwise unused sessions show up as USERNAME as a number 
    If (($RDPUser -match "[a-z]") -and ($RDPUser -ne $NULL)) {  
    
    Write-Host $ServerName logged in by $RDPUser on $sessionType 
                }
            }
        }
    }
    

    我从 powershell_ise 运行它并在第 22 行将 $RDPuser -match "%%%" 编辑为 $RDPuser -match "user1/2/3/" 以便为特定用户运行。如果您按原样运行它,它将显示所有通过 rdp 登录的用户。

    • 1

相关问题

  • 如果以域用户身份远程登录,PC 速度极慢

  • 如何在 Windows 2003 的 ou 级别应用策略

  • 允许用户更改其 Active Directory 密码的 Web 界面

  • MOSS 2007 无法使用 ActiveDirectoryMembershipProvider 配置表单身份验证

  • 通过 VPN 更改 Active Directory 密码

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve