In one system there are multiple users are logged in.
I would like to know which user logged and locked the system.
I tried to find the LogonUI.exe availability. but I am not getting proper username of the LogonUI.exe
$uname = $env:UserName
$procs = @()
$allProcs = @(Get-WmiObject win32_process)
foreach($proc in $allProcs)
{
if($proc.getowner().user -eq $uname) {
if($proc.ProcessName() -eq LogonUI) {
"system locked"
}
}
}
I tried this way. but even though user locked the system I am not getting it as locked. because it is failing at user name check. most of the time it is coming as blank. any help?