PowerShell script to get the user logged into a computer using a system account.
Get-WmiObject Win32_Process -f 'Name="explorer.exe"' |% getowner |% user
$sessionId = (Get-WmiObject Win32_Process -Filter 'Name="explorer.exe"').SessionId | Select-Object -Unique
msg.exe $sessionId "$message"
0 Comments