-3

How to identify which user is currently using the VM. That is the VM might have common login like administrator, test1 etc., but I want know which user/machine has launched the VM using mstsc from their machine and using it.

I want to fetch these information using C# or powershell code.

All the machines and VM's are in same domain.

All your suggestions are welcome.

4

1 回答 1

0

在 PowerShell 中,您可以这样做:

$sessions = gwmi -cn myvm -Query "Select * from Win32_LogonSession Where LogonType = 10"
$sessions | Foreach {gwmi -cn myvm -Query "Associators of {Win32_LogonSession.LogonID='$($_.LogonId)'} Where AssocClass=Win32_LoggedOnUser Role=Dependent"}
于 2013-10-04T20:04:26.213 回答