How to find Computer Screen is Locked or not using Powershell

Welcome Forums General PowerShell Q&A How to find Computer Screen is Locked or not using Powershell

This topic contains 3 replies, has 3 voices, and was last updated by

 
Participant
2 years, 3 months ago.

  • Author
    Posts
  • #53202

    Participant
    Points: 0
    Rank: Member

    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.

  • #53266

    Participant
    Points: 21
    Rank: Member

    You want the script only to run while locked?

    Look for EventID=4634 in the eventlog

  • #53274

    Participant
    Points: 21
    Rank: Member

    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

    }

  • #53338

    Participant
    Points: 1
    Rank: Member

    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

The topic ‘How to find Computer Screen is Locked or not using Powershell’ is closed to new replies.