Author Posts

September 2, 2016 at 2:37 pm

Hi All,

I am performing a GUI Based Automation through PowerShell , but the problem I am facing is the script will only run on an interactive session if the machine is locked, it waits to get unlocked. So is there any way to know if the machine is locked and if yes then how to login or make it run, just saying 😛

Lets have some idea on the this, and see this possibility.

September 2, 2016 at 5:53 pm

You want the script only to run while locked?

Look for EventID=4634 in the eventlog

September 2, 2016 at 6:15 pm

1..10 | % {

$currentuser = gwmi -Class win32_computersystem | select -ExpandProperty username
$process = get-process logonui -ea silentlycontinue

if($currentuser -and $process){"computer is locked"}else{"unlocked"}

start-sleep 5

}

September 3, 2016 at 6:54 pm

Amar,

This question came up a few years ago in one of my Server classes. Here is my posted solution. It is a combination of PowerShell and Advanced Auditing.

Jason

http://mctexpert.blogspot.com/2012/10/how-to-determine-if-client-on-your.html