PowerShell Logo Small

New-ScheduledTaskTrigger



This is the built-in help made by Microsoft for the command 'New-ScheduledTaskTrigger', 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 scheduled task trigger object.

SYNTAX


New-ScheduledTaskTrigger [-Once] [-RandomDelay <TimeSpan>] [-RepetitionDuration <TimeSpan>] [-RepetitionInterval <TimeSpan>] -At <DateTime> [<CommonParameters>]
New-ScheduledTaskTrigger [-Weekly] [-RandomDelay <TimeSpan>] [-WeeksInterval <Int32>] -At <DateTime> -DaysOfWeek {Sunday | Monday | Tuesday | Wednesday | Thursday | Friday |
Saturday} [<CommonParameters>]
New-ScheduledTaskTrigger [-Daily] [-DaysInterval <Int32>] [-RandomDelay <TimeSpan>] -At <DateTime> [<CommonParameters>]
New-ScheduledTaskTrigger [-AtLogOn] [-RandomDelay <TimeSpan>] [-User <String>] [<CommonParameters>]
New-ScheduledTaskTrigger [-AtStartup] [-RandomDelay <TimeSpan>] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


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.



<

RELATED LINKS

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

REMARKS

<

Examples


Example 1: Register a scheduled task that starts a task 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



This example registers a scheduled task that starts once.




Example 2: Register 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



This example registers a scheduled task that starts every day.




Example 3: Register 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



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




Example 4: Register 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



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




Example 5: Register 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



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