Windows Task Scheduler is a utility that helps to execute any process periodically. For example, you want to sync your working files on daily basis, scanning virus, process some data, etc. A task has the following components: Action or multiple actions - which is the process that you want to run periodically. We use New-ScheduledTaskAction to create new action object. Trigger - which is the time to run the process and it can have multiple timing. We use New-ScheduledTaskTrigger to create new trigger. Security context - any process must run in a valid security context. We can set the context using New-ScheduledTaskPrincipal. The following script creates an on demand task which requires user to manually trigger the task. $task_folder = "\myTasks\" $task_name = "myTask2" # this can be any Powershell script. $ps_script_file = "d:\temp5\test-script.ps1" ## The first line will show err if $task_folder does not exist. ## The second line will not...
Comments
Post a Comment