尝试跟随
- https://www.itprotoday.com/windows-8/use-powershell-list-rds-sessions
- https://powershelladministrator.com/2015/12/01/get-logged-on-users-and-sessions/
但失败了:
那么如何使用 PowerShell 列出远程 RDS 会话?
更新:
尝试使用Get-CimInstance -ClassName Win32_LogonSession -Filter "LogonType = 10"
,但它“不提取任何域用户帐户的用户名或 SSID,仅提取本地服务和会话”:
答案1
首先尝试连接到远程服务器,然后在那里导入模块:
Enter-PSSession -Computername 'RD-Server01'
Import-Module RemoteDesktop
RemoteDesktop
您也可以在本地机器上安装该模块:
Get-WindowsCapability -Online -Name Rsat.RemoteDesktop.Services.Tools* | Add-WindowsCapability -Online