

PS C:\> Register-ScheduledTask 'baz' -InputObject $task PS C:\> $task = New-ScheduledTask -Action $actions -Principal $principal -Trigger $trigger -Settings $settings PS C:\> $settings = New-ScheduledTaskSettingsSet -RunOnlyIfNetworkAvailable -WakeToRun PS C:\> $principal = New-ScheduledTaskPrincipal -UserId 'DOMAIN\user' -RunLevel Highest PS C:\> $trigger = New-ScheduledTaskTrigger -Daily -At '9:15 AM' Example 2: Define a scheduled task with multiple actions PS C:\> $actions = (New-ScheduledTaskAction -Execute 'foo.ps1'), (New-ScheduledTaskAction -Execute 'bar.ps1')

It registers the new scheduled task and defines it by using the $task variable. The sixth command (hypothetically) runs at a later time. The fifth command creates a new task and assigns the task definition to the variable $task. The fourth command uses the New-ScheduledTaskSettingsSet cmdlet to assign a task settings object to the variable $settings. The third command assigns the principal of the scheduled task Contoso\Administrator to the variable $principal. The second command uses the New-ScheduledTaskTrigger cmdlet to assign the value AtLogon to the variable $trigger. The first command uses the New-ScheduledTaskAction cmdlet to assign the executable file tskmgr.exe to the variable $action. In this example, the set of commands uses several cmdlets and variables to define and then register a scheduled task. PS C:\> Register-ScheduledTask T1 -InputObject $task PS C:\> $task = New-ScheduledTask -Action $action -Principal $principal -Trigger $trigger -Settings $settings PS C:\> $settings = New-ScheduledTaskSettingsSet PS C:\> $principal = "Contoso\Administrator" PS C:\> $trigger = New-ScheduledTaskTrigger -AtLogon Examples Example 1: Define a scheduled task and register it at a later time PS C:\> $action = New-ScheduledTaskAction -Execute "Taskmgr.exe" bat), command files (.cmd), or any properly registered file type. You can register a task to run any of the following application or file types: Win32 applications, Win16 applications, OS/2 applications, MS-DOS applications, batch files (. New-ScheduledTask does not automatically register the object with the Task Scheduler service. The New-ScheduledTask cmdlet creates an object that contains the definition of a scheduled task.

In this article Syntax New-Scheduled Task
