How to set priority on Windows scheduled task using group policy? is it possible?

375 views
Skip to first unread message

selahattin şadoğlu

unread,
Oct 18, 2023, 11:33:22 AM10/18/23
to ntsysadmin
Hello everyone,

In our environment we have Windows Server 2016 domain controllers with 2016 functional level, and lots of Windows 10 & 11 client machines.

We have created a gpo which copies some scripts to local computer folder and which creates the registry keys and which creates (with update option) a Scheduled task, which has to run at startup.

AFAIK,By default Windows setups task priority in scheduler to 7 (which is kinda low).

My question is : I want to change priority on Windows scheduled task using group policy? is it possible?

thanks,

Michael B. Smith

unread,
Oct 18, 2023, 11:37:11 AM10/18/23
to ntsys...@googlegroups.com

You can set the priority when you create the task. Or you can write a script that does nothing but update the priority. Pretty sure those are your choices.

--
You received this message because you are subscribed to the Google Groups "ntsysadmin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ntsysadmin+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ntsysadmin/9b1a1c65-a079-4092-a5ca-18594f83ba81n%40googlegroups.com.

maxcoder1

unread,
Oct 18, 2023, 4:10:43 PM10/18/23
to ntsys...@googlegroups.com
First of all ,thanks for your help. But , there is no priority setting inside GUI. (GPO Preferences) 

AFAIK , There is a powershell command like below.  

How to set priority on Windows scheduled task? What do you recommend?

$STSet = New-ScheduledTaskSettingsSet -Priority 5
Set-ScheduledTask -TaskName "[Your task name]" -Settings $STSet

image.png

Michael B. Smith

unread,
Oct 18, 2023, 6:57:45 PM10/18/23
to ntsys...@googlegroups.com

Your original post suggested that you were creating the scheduled tasks via scripts. It’s trivial to set the priority within your script. See a normal “create task” from one of my scripts:

 

[CmdletBinding()]

Param()

 

## create-eventNetworkTask

 

## needs to be run from an elevated session

 

Set-StrictMode -Version latest

 

$class   = Get-CimClass -ClassName MSFT_TaskEventTrigger -NameSpace root/Microsoft/Windows/TaskScheduler

$stTrig  = $class | New-CimInstance -ClientOnly

## $stTrig

 

$stTrig.Enabled      = $true

$stTrig.SubScription = '<QueryList><Query Id="0" Path="Microsoft-Windows-NetworkProfile/Operational"><Select Path="Microsoft-Windows-NetworkProfile/Operational">*[System[Provider[@Name=''Microsoft-Windows-NetworkProfile''] and EventID=10000]]</Select></Query></QueryList>'

 

$actionP =

@{

    Execute  = 'powershell.exe'

    Argument = '-NoLogo -NoProfile -File C:\ProgramData\zzzz\OnNetwork.ps1'

}

 

$stAction    = New-ScheduledTaskAction      @actionP

$stPrincipal = New-ScheduledTaskPrincipal   -UserID "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount -RunLevel Highest

$stSettings  = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -Priority 5

 

$regP =

@{

    TaskName    = 'Network change script'

    TaskPath    = '\'

    Action      = $stAction

    Principal   = $stPrincipal

    Settings    = $stSettings

    Trigger     = $stTrig

}

 

Register-ScheduledTask @regP

 

 

From: ntsys...@googlegroups.com <ntsys...@googlegroups.com> On Behalf Of maxcoder1
Sent: Wednesday, October 18, 2023 4:10 PM
To: ntsys...@googlegroups.com
Subject: Re: [ntsysadmin] How to set priority on Windows scheduled task using group policy? is it possible?

 

First of all ,thanks for your help. But , there is no priority setting inside GUI. (GPO Preferences) 

 

AFAIK , There is a powershell command like below.  

 

How to set priority on Windows scheduled task? What do you recommend?

 

$STSet = New-ScheduledTaskSettingsSet -Priority 5

Set-ScheduledTask -TaskName "[Your task name]" -Settings $STSet

 

 

On Wed, Oct 18, 2023 at 6:37 PM Michael B. Smith <mic...@smithcons.com> wrote:

You can set the priority when you create the task. Or you can write a script that does nothing but update the priority. Pretty sure those are your choices.

 

From: ntsys...@googlegroups.com <ntsys...@googlegroups.com> On Behalf Of selahattin sadoglu
Sent: Wednesday, October 18, 2023 11:33 AM
To: ntsysadmin <ntsys...@googlegroups.com>
Subject: [ntsysadmin] How to set priority on Windows scheduled task using group policy? is it possible?

 

Hello everyone,

In our environment we have Windows Server 2016 domain controllers with 2016 functional level, and lots of Windows 10 & 11 client machines.

We have created a gpo which copies some scripts to local computer folder and which creates the registry keys and which creates (with update option) a Scheduled task, which has to run at startup.

AFAIK,By default Windows setups task priority in scheduler to 7 (which is kinda low).

My question is : I want to change priority on Windows scheduled task using group policy? is it possible?

thanks,

--
You received this message because you are subscribed to the Google Groups "ntsysadmin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ntsysadmin+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ntsysadmin/9b1a1c65-a079-4092-a5ca-18594f83ba81n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "ntsysadmin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ntsysadmin+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ntsysadmin/a097cfe66a63468c8229ea7fa54a5060%40smithcons.com.

--
You received this message because you are subscribed to the Google Groups "ntsysadmin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ntsysadmin+...@googlegroups.com.

maxcoder1

unread,
Oct 19, 2023, 10:46:01 AM10/19/23
to ntsys...@googlegroups.com
Thanks again, btw, I have a GPO like below. is it make sense?

teams_scheduler.ps1 script ->  your power script which is create task scheduler (Priority :5 )
teams.ps1 

1.  I am copying to client pc your  teams add-in repair script (teams.ps1) and powershell script (teams_scheduler.ps1)which is creating the scheduled task like below. 

gpo1.png
gpo3.png


2. I am using immediate task scheduler to trigger teams_scheduler script  within the same gpo

This immediate task scheduler is creating another task scheduler for teams add-in repair.

gpo2.png






Reply all
Reply to author
Forward
0 new messages