


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
