PowerShell Logo Small

Set-ScheduledJobOption



This is the built-in help made by Microsoft for the command 'Set-ScheduledJobOption', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Changes the job options of a scheduled job.

SYNTAX


Set-ScheduledJobOption [-InputObject] <ScheduledJobOptions> [-ContinueIfGoingOnBattery] [-DoNotAllowDemandStart] [-HideInTaskScheduler] [-IdleDuration <TimeSpan>]
[-IdleTimeout <TimeSpan>] [-MultipleInstancePolicy <TaskMultipleInstancePolicy>] [-PassThru] [-RequireNetwork] [-RestartOnIdleResume] [-RunElevated] [-StartIfIdle]
[-StartIfOnBattery] [-StopIfGoingOffIdle] [-WakeToRun] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Set-ScheduledJobOptions cmdlet changes the job options of scheduled jobs.


To change the options of a scheduled job, begin by using the Get-ScheduledJobOption cmdlet to get the job options of a scheduled job. Then, pipe the options to
Set-ScheduledJobOption or save the options in a variable and use the InputObject parameter of Set-ScheduledJobOption cmdlet to identify the options. Use the remaining
parameters of Set-ScheduledJobOption to change the job options.


To turn on a job option, use the parameter that sets that option. To turn off an option, type the parameter name, a colon (:), and $false. For example, to turn off the
RunElevated option, type -RunElevated:$false.


Each job options object includes a JobDefinition property that contains the scheduled job, so the association with the scheduled job is retained when the job options are
changed.


The scheduled job options determine how the job runs when it is started by Task Scheduler. These options to not apply when you use the Start-Job cmdlet to start a scheduled
job.


Set-ScheduledJobOption is one of a collection of job scheduling cmdlets in the PSScheduledJob module that is included in Windows PowerShell.


For more information about Scheduled Jobs, see the About topics in the PSScheduledJob module. Import the PSScheduledJob module and then type: Get-Help about_Scheduled* or
see about_Scheduled_Jobs.


This cmdlet is introduced in Windows PowerShell 3.0.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=290634
about_Scheduled_Jobs
Add-JobTrigger
Disable-JobTrigger
Disable-ScheduledJob
Enable-JobTrigger
Enable-ScheduledJob
Get-JobTrigger
Get-ScheduledJob
Get-ScheduledJobOption
New-JobTrigger
New-ScheduledJobOption
Register-ScheduledJob
Remove-JobTrigger
Set-JobTrigger
Set-ScheduledJob
Set-ScheduledJobOption
Unregister-ScheduledJob

REMARKS

<

Examples


Example 1: Change job options

The first command uses the Get-ScheduledJobOption cmdlet to get the job options of the DeployPackage scheduled job. The output shows that the WakeToRun and RunElevated
properties are set to False.This command is not required; it is included only to show the effect of the option change.
PS C:\>Get-ScheduledJobOption -Name DeployPackage
StartIfOnBatteries : False
StopIfGoingOnBatteries : True
WakeToRun : False
StartIfNotIdle : True
StopIfGoingOffIdle : False
RestartOnIdleResume : False
IdleDuration : 00:10:00
IdleTimeout : 01:00:00
ShowInTaskScheduler : True
RunElevated : False
RunWithoutNetwork : False
DoNotAllowDemandStart : False
MultipleInstancePolicy : IgnoreNew
JobDefinition :

The second command uses the Set-ScheduledJobOpton cmdlet to change the job options so the values of the WakeToRun and RunWithoutNetwork properties are True. The command uses
the Passthru parameter to return the trigger after the change.
PS C:\>Get-ScheduledJobOption -Name DeployPackage | Set-ScheduledJobOption -WakeToRun -RequireNetwork:$False -Passthru
StartIfOnBatteries : False
StopIfGoingOnBatteries : True
WakeToRun : True
StartIfNotIdle : True
StopIfGoingOffIdle : False
RestartOnIdleResume : False
IdleDuration : 00:10:00
IdleTimeout : 01:00:00
ShowInTaskScheduler : True
RunElevated : False
RunWithoutNetwork : True
DoNotAllowDemandStart : False
MultipleInstancePolicy : IgnoreNewJobDefinition :



This example shows how to change the options of a scheduled job on the local computer.




Example 2: Change an option on all remote scheduled jobs

PS C:\>Invoke-Command -Computer Server01 -ScriptBlock {Get-ScheduledJob | Get-ScheduledJobOption | Set-ScheduledJobOption -IdleTimeout 2:00:00}



This command changes the value of the IdleTimeout from one hour (the default value) to two hours on all scheduled jobs on the Server01 computer.

The command uses the Invoke-Command cmdlet to run a command on the Server01 computer.

The remote command begins with a Get-ScheduledJob command that gets all scheduled jobs on the computer. The scheduled jobs are piped to the Get-ScheduledJobOption cmdlet,
which gets the job options of the scheduled jobs. Each job options object contains a JobDefinition property that contains the scheduled job, so the options object remains
associated with the scheduled job even when it is changed.

The job triggers are piped to the Set-ScheduledJobOption cmdlet, which changes the value of the IdleTimeout option to two hours (2:00:00).