An example/stub of how to create/edit a scheduled task with Powershell. This particular example calls the freely-available
idlelogoff.exe for auto-user logoff after 5 minutes of inactivity. While this particular example script calls a specific application, its intended purpose is to be used as a launchpad example for manipulating scheduled tasks for your environment.
An Important Note: The site hosting the download and documentation for
$action to something already on your testing workstation.
This script creates (or updates) a scheduled task to call
It may be most useful for situations with multi-user workstations (kiosk-style, presentation station, etc.) to ensure folks are safely logged off after a period of inactivity. Because people seem to forget...
This script must be run as an administrator, and (in order for the scheduled task to actually run) will require
idlelogoff.exe to be distributed to/available on the target workstation in a process separate from this task manager (e.g. application via SCCM, baked into a WIM, etc.).
When run without any edits, this script will create or edit a task matching
$taskName. The action calls
idlelogoff.exe with a "5 minute Logoff" (
300 LOGOFF) argument, sets the task trigger to any console user (
BUILTIN\Users) at log on (
For testing reasons, the
-Disable flag has been added to the task settings. This will create the task but not auto-enable. For production deployment, one would remove the
Much detail on how to extend the use of scheduled tasks can be found at https://docs.microsoft.com/en-us/powershell/module/scheduledtasks/ and https://docs.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtask
Bare-bones logging is also output to
$logPath and could be easily extended for one's own sanity or need.