PowerShell Logo Small

New-ScheduledTaskSettingsSet



This is the built-in help made by Microsoft for the command 'New-ScheduledTaskSettingsSet', 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

Creates a new scheduled task settings object.

SYNTAX


New-ScheduledTaskSettingsSet [-AllowStartIfOnBatteries] [-AsJob] [-CimSession <CimSession[]>] [-Compatibility <CompatibilityEnum>] [-DeleteExpiredTaskAfter <TimeSpan>]
[-Disable] [-DisallowDemandStart] [-DisallowHardTerminate] [-DisallowStartOnRemoteAppSession] [-DontStopIfGoingOnBatteries] [-DontStopOnIdleEnd] [-ExecutionTimeLimit
<TimeSpan>] [-Hidden] [-IdleDuration <TimeSpan>] [-IdleWaitTimeout <TimeSpan>] [-MaintenanceDeadline <TimeSpan>] [-MaintenanceExclusive] [-MaintenancePeriod <TimeSpan>]
[-MultipleInstances <MultipleInstancesEnum>] [-NetworkId <String>] [-NetworkName <String>] [-Priority <Int32>] [-RestartCount <Int32>] [-RestartInterval <TimeSpan>]
[-RestartOnIdle] [-RunOnlyIfIdle] [-RunOnlyIfNetworkAvailable] [-StartWhenAvailable] [-ThrottleLimit <Int32>] [-WakeToRun] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The New-ScheduledTaskSettingsSet cmdlet creates an object that contains scheduled task settings. Each scheduled task has one set of task settings. Use this cmdlet to
configure options to manage the behavior of the task upon completion, to manage the behavior of the task if a problem occurs, or to manage the behavior of the task if an
instance of the task is already running.


You can use the scheduled task settings to register a new scheduled task or update an existing task registration.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=287554
Register-ScheduledTask
New-ScheduledTask
Get-ScheduledTask
Get-ScheduledTaskInfo
Unregister-ScheduledTask
Enable-ScheduledTask
Start-ScheduledTask

REMARKS

<

Examples


Example 1: Register a scheduled task that uses default task settings

The first command creates a scheduled task action named Cmd and assigns the ScheduledTaskAction object to the Sta variable.
PS C:\>$Sta = New-ScheduledTaskAction -Execute "Cmd"

The second command creates scheduled task settings that use the default settings and assigns the ScheduledTaskSettings object to the Stset variable.
PS C:\>$STSet = New-ScheduledTaskSettingsSet

The third command registers the scheduled task Task01 to run the task action named Cmd and to use the default task settings.
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Settings $STSet



This example registers a scheduled task that uses default task settings.




Example 2: Set the priority of a scheduled task

The first command creates a scheduled task action named Cmd and assigns the ScheduledTaskAction object to the Sta variable.
PS C:\>$Sta = New-ScheduledTaskAction -Execute "Cmd"

The second command creates scheduled task settings that sets a higher priority for the scheduled task, and assigns the ScheduledTaskSettings object to the Stset variable.
PS C:\>$STSet = New-ScheduledTaskSettingsSet -Priority 5

The third command registers the scheduled task Task01 to run the task action named Cmd and to use the task settings that have a priority setting of 9.
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Settings $Stset



This example sets the priority of a scheduled task.




Example 3: Set restart settings for a scheduled task

The first command creates a scheduled task action named Cmd and assigns the ScheduledTaskAction object to the Sta variable.
PS C:\>$Sta = New-ScheduledTaskAction -Execute "Cmd"

The second command creates scheduled task settings that specify that Task Scheduler attempts three restarts of the task at sixty minute intervals. This command assigns the
ScheduledTaskSettings object to the Stset variable.
PS C:\>$Stset = New-ScheduledTaskSettingsSet -RestartCount 3 -RestartInterval 60

The third command registers the scheduled task Task01 to run the task action named Cmd and to use the task settings that the ScheduledTaskSettings object defines.
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Settings $Stset



This example sets restart settings for a scheduled task.




Example 4: Set idle settings for a scheduled task

The first command creates a scheduled task action named Cmd and assigns the ScheduledTaskAction object to the Sta variable.
PS C:\>$Sta = New-ScheduledTaskAction -Execute "Cmd"

The second command creates scheduled task settings that specify that Task Scheduler runs the task only when the computer is idle for 2 minutes and waits for 2 hours and 30
minutes for an idle condition. This command assigns the ScheduledTaskSettings object to the Stset variable.
PS C:\>$Stset = New-ScheduledTaskSettingsSet -RunOnlyIfIdle -IdleDuration 00:02:00 -IdleWaitTimeout 02:30:00

The third command registers the scheduled task Task01 to run the task action named Cmd and to use the task settings that the ScheduledTaskSettings object defines.
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Settings $Stset



This example sets idle settings for a scheduled task.




Example 5: Register a scheduled task that runs only when a network is available

The first command creates a scheduled task action named Cmd and assigns the ScheduledTaskAction object to the Sta variable.
PS C:\>$Sta = New-ScheduledTaskAction -Execute "Cmd"

The second command creates scheduled task settings that specify that Task Scheduler runs the task only when a network is available. This command assigns the
ScheduledTaskSettings object to the Stset variable.
PS C:\>$Stset = New-ScheduledTaskSettingsSet -RunOnlyIfNetworkAvailable

The third command registers the scheduled task Task01 to run the task action named Cmd only when a network is available.
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Settings $Stset



This example registers a scheduled task that runs only when a network is available.