How to create scheduled task using GPO? , Ranjan.info

You can use Group Policy to create and deploy scheduled tasks for domain computers. For example, you can create a task that automatically logs users out or shuts down the computer 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 delivers it to users’ computers by 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 the users or computers you want to assign the task to (if you assign the GPO to the OU containing the computers, enable Configure User Group Policy Loopback Processing Mode Under Computer Configuration -> Administrative Templates -> System -> Group Policy, see guide here);
    Create a Windows Scheduled Tasks GPO
  2. Go to User Configuration -> Preferences -> Control Panel Settings -> Scheduled Tasks;
  3. Create a new scheduled task: New -> Scheduled Tasks (at least Windows 7), Create a new scheduled task item using Group Policy
  4. You will see a form similar to the standard Windows Scheduler Task Configuration window. configure the settings of your work;
  5. But Normal tab, action = set Update, enter the name of the job. To run the job on behalf of the current user, enter %LogonDomain%\%LogonUser% here. To run the task as administrator, check run with elevated privileges alternative; Configure scheduled work items with Group Policy preferences
  6. navigate to triggers tab. Specify the date and time you want the job to run. In my case, it’s every day at 5 PM. Select New -> Start Task on a schedule -> Daily, and specify the time to start the task;
    run a job on a schedule
  7. On the Actions tab, specify a command or a script that you want to run using Task Scheduler. Configure the following task options:
    action:start a program
    program/script, C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe
    add argument (optional), -ExecutionPolicy Bypass -command "& \\woshub.com\SysVol\woshub.com\scripts\ShowReminder.ps1"Run a PowerShell Script Through Task Scheduler
  8. Restart the user’s computer to apply the GPO. Open Task Scheduler (taskschd.msc) and make sure that a new task has appeared in the Task Scheduler library. Make sure to run according to the timetable.
    new task appeared in scheduler

Note that unlike the GPO logon script you can configure it to run only when the computer is on/off or when a user is logon/logout, scheduled tasks can be run at any time or after a specific trigger event Can See an example of running a script (performing an action) while starting (exiting) an app in Windows.

Leave a Comment