Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

 Windows OS Hub / Group Policies / How to Create a Scheduled Task Using GPO

March 17, 2024 Active DirectoryGroup PoliciesPowerShellWindows 10Windows Server 2019

How to Create a 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).
    Create 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 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;
    If you create a task in the Computer Configuration GPO section, you may run the job on behalf of the system (NT AUTHORITY\System).
    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:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe
    Add Arguments (optional): -ExecutionPolicy Bypass -command "& \\woshub.com\SysVol\woshub.com\scripts\ShowReminder.ps1"run a powershell script via task sheduler
    You copy the file of your PS1 script to user computers using GPO or run it directly from the UNC path. In my example, I am running a PowerShell script that displays a pop-up notification from the SYSVOL directory on the domain controller. To bypass the PowerShell script Execution Policy, I use the -ExecutionPolicy Bypass option.
  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
You can run the scheduled task manually in PowerShell using this command:
Start-ScheduledTask YourTaskName1

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.

1 comment
3
Facebook Twitter Google + Pinterest
previous post
Enable HTTP/3 Support for IIS on Windows Server 2022
next post
Shutdown/Restart Windows using Command Prompt and PowerShell

Related Reading

Configure NTP Time Source for Active Directory Domain

May 6, 2025

View Windows Update History with PowerShell (CMD)

April 30, 2025

Change BIOS from Legacy to UEFI without Reinstalling...

April 21, 2025

Uninstalling Windows Updates via CMD/PowerShell

April 18, 2025

Allowing Ping (ICMP Echo) Responses in Windows Firewall

April 15, 2025

1 comment

Dk March 12, 2023 - 8:20 am

I have created a FailedLogon task in GPO. The task gets deployed if I run it as SYSTEM. But when trying to run it under a service account srv_tasks it doesn’t schedule the task. And in the event logs I see this:

The computer ‘FailedLogonTask’ preference item in the ‘FailedLogonTask’ Group Policy Object did not apply because it failed with error code ‘0x80070005 Access is denied.’ This error was suppressed

Reply

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMware
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025
  • AD Domain Join: Computer Account Re-use Blocked

    March 11, 2025
  • How to Write Logs to the Windows Event Viewer from PowerShell/CMD

    March 3, 2025
  • How to Hide (Block) a Specific Windows Update

    February 25, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Configure Google Chrome Settings with Group Policy
  • Get-ADUser: Find Active Directory User Info with PowerShell
  • Allow Non-admin Users RDP Access to Windows Server
  • How to Find the Source of Account Lockouts in Active Directory
  • How to Disable or Enable USB Drives in Windows using Group Policy
  • Get-ADComputer: Find Computer Properties in Active Directory with PowerShell
  • Configuring Proxy Settings on Windows Using Group Policy Preferences
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top