It’s not overly tough, but you need to do a little text parsing, and the idea of a brief description of the activity is far too vague..
Unfortunately, I don’t have a lot of time to dig in and get the correct regex (I’ve got it stored on my work computer).. you’ll combine the output of quser/qwinsta and qprocess.
$ComputerList = 'server1','server2'
foreach ($Computer in $ComputerList) {
qwinsta /server:$Computer | foreach-object {
$_ -match '[ >](?\w+)\s+(?\w+)\s+(?\d+)\s+?(?\w+)'
$ResultHash = @{
UserName = $matches.username
SessionID = $matches.SessionID
ServerName = $Computer
}
$ProcessList = qprocess /id:$ResultHash['SessionID'] /server:$Computer | foreach-object {
$_ -match '[ >](<!--?UserName >\w+)\s+(<?SessionName>\w+)\s+(<?SessionID>\d+)\s+(<?PID>\d+)\s+(<?ProcessName>\w+)'<br ?->
$ResultHash['ProcessList'] = $Matches.ProcessName -join ','
}
$ResultHash | Select-object -property UserName,SessionID,ServerName,ProcessList
}
Sorry..the code block here blew off the indentation. But that should get you started… the clientname is much harder to get without WMI, and even that’s not simple..
David F.