New-ScheduledTaskTrigger

Windows Server 2012 R2 and Windows 8.1

New-ScheduledTaskTrigger

Creates a scheduled task trigger object.

Sintaxis

Parameter Set: Once
New-ScheduledTaskTrigger [-Once] -At <DateTime> [-RandomDelay <TimeSpan> ] [-RepetitionDuration <TimeSpan> ] [-RepetitionInterval <TimeSpan> ] [ <CommonParameters>]

Parameter Set: AtLogon
New-ScheduledTaskTrigger [-AtLogOn] [-RandomDelay <TimeSpan> ] [-User <String> ] [ <CommonParameters>]

Parameter Set: AtStartup
New-ScheduledTaskTrigger [-AtStartup] [-RandomDelay <TimeSpan> ] [ <CommonParameters>]

Parameter Set: Daily
New-ScheduledTaskTrigger [-Daily] -At <DateTime> [-DaysInterval <Int32> ] [-RandomDelay <TimeSpan> ] [ <CommonParameters>]

Parameter Set: Weekly
New-ScheduledTaskTrigger [-Weekly] -At <DateTime> -DaysOfWeek {Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday}[] [-RandomDelay <TimeSpan> ] [-WeeksInterval <Int32> ] [ <CommonParameters>]




Descripción detallada

The New-ScheduledTaskTrigger cmdlet creates and returns a new scheduled task trigger object.

You can use a time-based trigger or an event-based trigger to start a task. Time-based triggers include starting a task at a specific time or starting a task multiple times on a daily or weekly schedule. Event-based triggers include starting a task when the system starts up or when a user logs on to the computer. Each task can contain one or more triggers, which means there are many ways that you can start a task. If a task has multiple triggers, Task Scheduler starts the task when any of the triggers occur.

Parámetros

-At<DateTime>

Specifies a date and time to trigger the task. This paramater is valid for calendar-based triggers (Once, Daily, Weekly).


Alias

ninguno

¿Requerido?

true

¿Posición?

named

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-AtLogOn

Indicates that a trigger starts a task when a user logs on.


Alias

ninguno

¿Requerido?

true

¿Posición?

1

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-AtStartup

Indicates that a trigger starts a task when the system is started.


Alias

ninguno

¿Requerido?

true

¿Posición?

1

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-Daily

Indicates that a trigger starts a task on a recurring daily schedule.


Alias

ninguno

¿Requerido?

true

¿Posición?

1

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-DaysInterval<Int32>

Specifies the interval between the days in the schedule. An interval of 1 produces a daily schedule. An interval of 2 produces an every-other day schedule.


Alias

ninguno

¿Requerido?

false

¿Posición?

named

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-DaysOfWeek<DayOfWeek[]>

Specifies an array of the days of the week on which Task Scheduler runs the task.


Alias

ninguno

¿Requerido?

true

¿Posición?

named

Valor predeterminado

{ DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday, DayOfWeek.Saturday, DayOfWeek.Sunday }

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-Once

Indicates that a trigger starts a task once at a time specified in the At parameter.


Alias

ninguno

¿Requerido?

true

¿Posición?

1

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-RandomDelay<TimeSpan>

Specifies a random amount of time to delay the start time of the trigger. The delay time is a random time between the time the task triggers and the time that you specify in this setting.


Alias

ninguno

¿Requerido?

false

¿Posición?

named

Valor predeterminado

0

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-RepetitionDuration<TimeSpan>

Specifies how long the repetition pattern repeats after the task starts.


Alias

ninguno

¿Requerido?

false

¿Posición?

named

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-RepetitionInterval<TimeSpan>

Specifies an amount of time between each restart of the task. The task will run, wait for the time interval specified, and then run again. This cycle continues for the time that you specify for the RepetitionDuration parameter.


Alias

ninguno

¿Requerido?

false

¿Posición?

named

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-User<String>

Specifies the identifier of the user for a trigger that starts a task when a user logs on.


Alias

ninguno

¿Requerido?

false

¿Posición?

named

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-Weekly

Indicates that the trigger starts a task on a recurring weekly schedule.


Alias

ninguno

¿Requerido?

true

¿Posición?

1

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-WeeksInterval<Int32>

Specifies the interval between the weeks in the schedule. An interval of 1 produces a weekly schedule. An interval of 2 produces an every-other week schedule.


Alias

ninguno

¿Requerido?

false

¿Posición?

named

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

<CommonParameters>

Este cmdlet admite los siguientes parámetros comunes: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer y -OutVariable. Para obtener más información, consulte about_CommonParameters (http://go.microsoft.com/fwlink/p/?LinkID=113216).

Entradas

El tipo de entrada es el tipo de los objetos que se pueden canalizar al cmdlet.

Salidas

El tipo de resultado es el tipo de objetos que emite el cmdlet.

  • Microsoft.Management.Infrastructure.CimInstance#MSFT_TaskTrigger

Ejemplos

Example 1: Register a scheduled task that starts a task once

This example registers a scheduled task that starts once.


 

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 a scheduled task trigger that starts the task once at 3:00 A.M and assigns the ScheduledTaskTrigger object to the Stt variable.


PS C:\> $Stt = New-ScheduledTaskTrigger -Once -At 3am

 

The third command registers the scheduled task Task01 to run the task action named Cmd once at 3:00 A.M.


PS C:\> Register-ScheduledTask Task01 -Action $Sta -Trigger $Stt

Example 2: Register a scheduled task that starts every day

This example registers a scheduled task that starts every day.


 

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 a scheduled task trigger that starts every day at 3:00 A.M and assigns the ScheduledTaskTrigger object to the Stt variable.


PS C:\> $Stt = New-ScheduledTaskTrigger -Daily -At 3am

 

The third command registers the scheduled task Task01 to run the task action named Cmd every day at 3:00 A.M.


PS C:\> Register-ScheduledTask Task01 -Action $Sta -Settings $Stt

Example 3: Register a scheduled task that starts every 3 days

This example registers a scheduled task that starts every 3 days.


 

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 a scheduled task trigger that starts every 3 days at 3:00 A.M and assigns the ScheduledTaskTrigger object to the Stt variable.


PS C:\> $Stt = New-ScheduledTaskTrigger -Daily -DaysInterval 3 -At 3am

 

The third command registers the scheduled task Task01 to run the task action named cmd every 3 days at 3:00 A.M.


PS C:\> Register-ScheduledTask Task01 -Action $Sta -Settings $Stt

Example 4: Register a scheduled task that starts every-other week

This example registers a scheduled task that starts every other week.


 

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 a scheduled task trigger that starts every other Sunday at 3:00 A.M and assigns the ScheduledTaskTrigger object to the Stt variable.


PS C:\> $Stt = New-ScheduledTaskTrigger -Weekly -WeeksInterval 2 -DaysOfWeek Sunday -At 3am

 

The third command registers the scheduled task Task01 to run the task action named Cmd every other Sunday at 3:00 A.M.


PS C:\> Register-ScheduledTask Task01 -Action $Sta -Settings $Stt

Example 5: Register a scheduled task that starts when a user logs on

This example registers a scheduled task that starts when a user logs on.


 

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 a scheduled task trigger that starts when a user logs on, and assigns the ScheduledTaskTrigger object to the Stt variable.


PS C:\> $Stt = New-ScheduledTaskTrigger -AtLogon

 

The third command registers the scheduled task Task01 to run the task action named Cmd when a user logs on.


PS C:\> Register-ScheduledTask Task01 -Action $Sta -Settings $Stt

Temas relacionados

Adiciones de comunidad

AGREGAR
Mostrar: