GPO to log out idle users

Edwald Neo 51 Reputation points
2022-08-26T05:29:18.723+00:00

Dear All,
Is there any GPOs or task schedulers methods that can log out idle users ?

Pls assist.

Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,724 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,083 questions
Remote Desktop
Remote Desktop
A Microsoft app that connects remotely to computers and to virtual apps and desktops.
4,226 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Reza-Ameri 16,826 Reputation points
    2022-08-27T16:25:39.903+00:00

    You could do this using Task Schedule, you will need to create a task and set it to Run only when user is logged on and select Conditions and check the box to Start the task only when computer is idle for ** and set the time when you want system log out when idle like 10 minutes. Under **Actions tab set to run a program and add the following script

    shutdown -L  
    

    To log off the user.

    0 comments No comments

  2. Mike Kerr 1 Reputation point
    2024-01-09T19:29:09.11+00:00

    Here's how we just did this:

    created a text file with the line: C:\Windows\System32\shutdown.exe /l /f and then changed the extension to .cmd

    then, created a local scheduled task to run that .cmd file after targeting the folder we want it to ultimately be in locally. For our example, we located the .cmd file in C:@installers\Scripts

    Once we tested that the Scheduled Task worked, we exported it to an XML file.

    We then put those files on a universally available/accessible share

    Next step we created an OU and put the targeted machines in there. Created a GPO in that OU that first copied those files from the share to the local folder on the machine and set it to Update (in case we wanted to update the way either file functioned down the road.) We did this under the computer configuration. Then under user configuration, we created a scheduled task on logon to:

    Run: pwsh.exe

    Arguments: -ExecutionPolicy Bypass -File "\FILEPATH\AutoLogoff.ps1" or whatever you name your PS1 file

    Start in: C:\Program Files\PowerShell\7\ (we have Powershell 7 installed in our image by default. You location may vary)

    The Powershell file has a single line to import the XML scheduled task:

    Register-ScheduledTask -Xml (Get-Content '\path to file\AutoLogoff.xml' | Out-String) -TaskName "AutoLogoff" -Force

    Hope that helps

    0 comments No comments