Scheduled Task with multiple actions

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Matt Bloomfield Matt Bloomfield 7 months, 2 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #35342
    Profile photo of David Jones
    David Jones
    Participant

    Is it possible to use PowerShell to register a scheduled task with multiple actions?

    #35369
    Profile photo of Matt Bloomfield
    Matt Bloomfield
    Participant

    Yes, you can specify an array of up to 32 actions.

    Quick example with 3 actions:

    $actions = @()
    
    $actions += New-ScheduledTaskAction -Execute 'notepad.exe'
    $actions += New-ScheduledTaskAction -Execute 'calc.exe'
    $actions += New-ScheduledTaskAction -Execute 'taskmgr.exe'
    
    $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddMinutes(1)
    
    $description = 'Test Task'
    
    $task = New-ScheduledTask -Action $actions -Trigger $trigger -Description $description
    
    Register-ScheduledTask TestTask -InputObject $task
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.