I'm trying to identify logged sessions using a WMI query using PowerShell with:
$logon_sess = @(gwmi win32_logonsession -ComputerName $computername)
But I see that this command is also reporting older sessions, are these still active? How can I reset it?
And when I compare the results with the "query user" command, I see different results because "Query user" command returns only current sessions.
Then, how can I get real result of existing sessions using WMI Win32_LogonSession method?