concept trigger in category powershell

appears as: trigger, triggers
Windows PowerShell in Action, Third Edition

This is an excerpt from Manning's book Windows PowerShell in Action, Third Edition.

The scheduled task is registered (created) 6 using the trigger and actions previously defined. You can then run the workflow 7 as a job.

Once you have the trigger defined, you can create the scheduled job:

PS> Register-ScheduledJob -Name PiASJ1 -ScriptBlock {Get-Process} `
-Trigger $t -RunNow

Id   Name     JobTriggers     Command        Enabled
--   ----     -----------     -------        -------
1    PiASJ1   1               Get-Process    True

You specify the job’s name, a scriptblock for the job to execute, and the trigger. You can use the -RunNow parameter of Register-ScheduledJob to run the job once as you register it. This is a useful test to ensure that everything works correctly.

Once you’ve created a scheduled job, you can modify a number of features. Let’s start with the trigger.