How to execute a power script with Windows Task Scheduler

This guide shows you how to set up Windows Task Scheduler in order to run a power script with it every 10 minutes. It is helpful if you enable SQL Text logging for high performance configurations.

Task Scheduler allows you to automate many tasks on Windows 10. With this tool, you can start applications, run commands, and execute scripts at a particular day and time, or you can also trigger tasks when a specific event occurs. To create a task using advanced settings using the Task Scheduler open the windows start menu and search for Task Scheduler, click the top result to open the experience (Figure 1).

open task scheduler
Figure 1 - Open Task Scheduler

Expand the "Task Scheduler Library" branch, and click the Action menu. Then select the Create Task option as you can see it in the Figure 2.

create new task
Figure 2 - Create new task

In the "Name" field, type a short descriptive name for the task. For example, Ozeki database import.

define task name
Figure 3 - Define task name

Now select the Trigger tab and click the New button. When you create a task, you can specify the conditions that will trigger the task (Figure 4).

add new trigger
Figure 4 - Add new trigger

In the new trigger page Advanced section check the "Repeat task every:" option. Here select the 10 minutes option and the "for a duration of:" will be indefinitely as the Figure 5 shows.

define task running time
Figure 5 - Define task running time

Now back in the Create Task page select the Action tab and click the New button. When you create a task, you must specify the action that will occur when your task starts (Figure 6).

add new action
Figure 6 - Add new action

In the New Action page under the "Settings" section, in the "Program/script" field, specify the path for the Ozeki import database power shell script. In this example it is located in C:\Ozeki as you can see in the Figure 7.

browse import script
Figure 7 - Browse import script

Finally in the Task Scheduler Library you will see the newly created scheduled task (Figure 8).

scheduled task created
Figure 8 - Scheduled task created

The last but very important step is to remove the endless loop from the script so delete that section form the importdb.ps1 file as you can see in the Figure 9.

modify script
Figure 9 - Modify script

More information