Export (0) Print
Expand All

New-ScheduledTaskSettingsSet

Updated: October 30, 2012

Applies To: Windows Server 2012

New-ScheduledTaskSettingsSet

Creates a new scheduled task settings object.

Syntax

Parameter Set: NewSettings1
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>]




Detailed 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.

Parameters

-AllowStartIfOnBatteries

Indicates that Task Scheduler starts if the computer is running on battery power.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-AsJob

Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete. The cmdlet immediately returns an object that represents the job and then displays the command prompt. You can continue to work in the session while the job completes. To manage the job, use the *-Job cmdlets. To get the job results, use the Receive-Job cmdlet. For more information about Windows PowerShell® background jobs, see about_Jobs.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-CimSession<CimSession[]>

Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.


Aliases

Session

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Compatibility<CompatibilityEnum>

Indicates which version of Task Scheduler with which a task is compatible. The acceptable values for this parameter are: 
-- At
-- V1
-- Vista
-- Win7
-- Win8


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DeleteExpiredTaskAfter<TimeSpan>

Specifies the amount of time that Task Scheduler waits before deleting the task after it expires.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Disable

Indicates that the task is disabled.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DisallowDemandStart

Indicates that the task cannot be started by using either the Run command or the Context menu.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DisallowHardTerminate

Indicates that the task cannot be terminated by using TerminateProcess.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DisallowStartOnRemoteAppSession

Indicates that the task does not start if the task is triggered to run in a Remote Applications Integrated Locally (RAIL) session.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DontStopIfGoingOnBatteries

Indicates that the task does not stop if the computer switches to battery power.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DontStopOnIdleEnd

Indicates that Task Scheduler does not terminate the task if the idle condition ends before the task is completed.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ExecutionTimeLimit<TimeSpan>

Specifies the amount of time that Task Scheduler is allowed to complete the task.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Hidden

Indicates that the task is hidden in the Task Scheduler UI.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-IdleDuration<TimeSpan>

Specifies the amount of time that the computer must be in an idle state before Task Scheduler runs the task.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-IdleWaitTimeout<TimeSpan>

Specifies the amount of time that Task Scheduler waits for an idle condition to occur.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-MaintenanceDeadline<TimeSpan>

Specifies the amount of time after which Task Scheduler attempts to run the task during emergency Automatic maintenance, if the task failed to complete during regular Automatic maintenance.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-MaintenanceExclusive

Indicates that the task needs to run alone when it is started in maintenance mode.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-MaintenancePeriod<TimeSpan>

Specifies the amount of time that the task needs to run once during regular Automatic maintenance.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-MultipleInstances<MultipleInstancesEnum>

Specifies the policy that defines how Task Scheduler handles multiple instances of the task.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-NetworkId<String>

Specifies the ID of a network profile that Task Scheduler uses to determine if the task can run. You must specify the ID of a network if you specify the RunOnlyIfNetworkAvailable paramater.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-NetworkName<String>

Specifies the name of a network profile that Task Scheduler uses to determine if the task can run. The Task Scheduler UI uses this setting for display purposes. Specify a network name if you specify the RunOnlyIfNetworkAvailable paramater.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Priority<Int32>

Specifies the priority level of the task. Priority must be an integer from 1 (lowest priority) to 10 (highest priority). The default value is 7.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RestartCount<Int32>

Specifies the number of times that Task Scheduler attempts to restart the task.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RestartInterval<TimeSpan>

Specifies the amount of time that Task Scheduler attempts to restart the task.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RestartOnIdle

Indicates that Task Scheduler restarts the task when the computer cycles into an idle condition more than once.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RunOnlyIfIdle

Indicates that Task Scheduler runs the task only when the computer is idle.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RunOnlyIfNetworkAvailable

Indicates that Task Scheduler runs the task only when a network is available. Task Scheduler uses the NetworkID paramater and NetworkName parameter that you specify in this cmdlet to determine if the network is available.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-StartWhenAvailable

Indicates that Task Scheduler can start the task at any time after its scheduled time has passed.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ThrottleLimit<Int32>

Specifies the maximum number of concurrent operations that can be established to run the cmdlet. If this parameter is omitted or a value of 0 is entered, then Windows PowerShell® calculates an optimum throttle limit for the cmdlet based on the number of CIM cmdlets that are running on the computer. The throttle limit applies only to the current cmdlet, not to the session or to the computer.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WakeToRun

Indicates that Task Scheduler wakes the computer before it runs the task.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Microsoft.Management.Infrastructure.CimInstance#MSFT_TaskSettings

Examples

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

This example registers 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

Example 2: Set the priority of a scheduled task

This example sets 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

Example 3: Set restart settings for a scheduled task

This example sets 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

Example 4: Set idle settings for a scheduled task

This example sets 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

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

This example registers 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

Related topics

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft