From my last post about checking if your VMs are backed up with a PowerCLI script, I have been asked how to add this as a scheduled task.
The answer is fairly simple.
On a Windows Server at least (2012R2 in this example)
- Open Task Scheduler
- Select Task Scheduler Library on the left navigation pane
- Right click in the white space on the right pane & select Create New Task
- Create a new Scheduled task
- Complete the fields below:
Under triggers (Change as required)
Under Actions, select New…
- Action: Start a Program
- Program\Script will be the path to PowerShell, for example: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
- Add arguments will be: -ExecutionPolicy Bypass -File “C:\Scripts\script.ps1”
Change the path of the script to your own path
If you want to run multiple scripts at the same time, add them all here:
There usually isn’t any need for conditions so skip to Settings:
You might want to set the task to stop after 15 minutes, or sometime longer than the script is supposed to take. This 3 day example might be too long for most scenarios.
- Select OK & Enter credentials when prompted
- Right click the new task and select Run to test it
You can also check the history of the task by selecting it and choosing the history tab on the bottom pane
That’s it! #Automation