Deploy Scheduled Task Using GPO

Deploy Scheduled Task Using GPO

You can use the Group Policy to create and deploy scheduled tasks to domain computers. For example, you can create a task that automatically logs out users or shuts down computers at a specified time, runs a script, etc.

In this example, we will create a new Scheduler task that displays a pop-up notification and distribute it to users’ computers using Group Policy Preferences.

  1. Open the Group Policy Management console (gpmc.msc), create a new GPO, and link it to an Organizational Unit with users or computers you want to assign the task to (if you assign the GPO to an OU with computers, enable the Configure user Group Policy Loopback Processing mode under Computer Configuration -> Administrative Templates -> System -> Group Policy, see the guide here);
    Create a Windows Schedule Task GPO
  2. Go to User Configuration -> Preferences -> Control Panel Settings -> Scheduled Tasks;
  3. Create a new scheduled task: New -> Scheduled task (At least Windows 7);The Immediate Task (at least Windows 7) item allows to create of a task that will run only once, but as quickly as possible (immediately after the next Group Policy update on the client).
  4. You will see a form similar to the standard Windows Scheduler task configuration window. Configure the settings of your task;
  5. On the General tab, set Action = Update, enter the task name. To make the task run on behalf of the current user, enter %LogonDomain%%LogonUser% here. To run the task as administrator, check the Run with highest privileges option;Configure a scheduled task item with Group Policy Preferences
  6. Navigate to the Triggers tab. Specify the date and time when you want to run the task. In my case, it is 5 PM every day. Select New -> Begin the task On a schedule -> Daily, and specify the time to start the task;
    run a task on a schedule
  7. On the Actions tab, specify a command or a script you want to run using the Task Scheduler. Configure the following task options:
    Action: Start a program
    Program/Script: C:WINDOWSsystem32WindowsPowerShellv1.0powershell.exe
    Add Arguments (optional): -ExecutionPolicy Bypass -command "& \wdigitalgeekery.comSysVoldigitalgeekery.comscriptsShowReminder.ps1"run a powershell script via task sheduler
  8. Restart a user’s computer to apply the GPO. Open the Task Scheduler (taskschd.msc) and make sure that a new task has appeared in the Task Scheduler Library. Make sure that it is run according to the schedule.
    New task appeared in Scheduler

Note that unlike GPO logon scripts you may configure it to be run only when a computer is started/shutdown or when a user logon/logout, scheduled tasks can be run at any time or after a specific trigger event occurs. See an example of how to run a script (do an action) when starting (exiting from) an app in Windows.

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *