# Powershell Script for Always On VirtualBox VMs

## Preparation

1. Download the VMs_Always_On Powershell script Download
2. Open the downloaded VMs_Always_on.ps1 file in a text editor
3. Edit the following:
   1. Set the $vboxPath variable to the install path of VirtualBox if it's not installed to the default location
   2. Set the $alwaysRunningVMs variable, adding the list of VM names or UUIDs to keep running (These values are case sensitive)
4. Save the changes
5. Copy the file to a location it will run from, c:\scripts for example

## Scheduled Task: Manual Method

1. Click on the Start Button > Type task > Launch Task Scheduler
2. Right click the Task Scheduler Library folder in the left pane > Create Basic Task...
3. Set the name to VMs Always On and optionally set a Description > Click Next
4. For the Trigger, select When the computer starts > Click Next
5. For the Action, select Start a program > Click Next
6. In the Program/script field, paste the following:

   C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

7. In the Add arguments field, paste the following, editing the path to the .ps1 file if necessary:

   -NoLogo -NoProfile -ExecutionPolicy Bypass -File "C:\Scripts\VMs_Always_On.ps1"

8. Click Next
9. Check the Open the Properties dialog for this task when I click Finish box
10. Click Finish
11. In the Properties dialog, select Run whether user is logged on or not
12. Select the Triggers tab and click the Edit... button
13. Check the Repeat task every: box and set the value to 5 minutes
14. Set the for a duration of value to Indefinitely
15. Click OK to accept the triggers
16. Click OK again to create the scheduled task
17. Enter the password for the user the task will run as
18. To test, stop at least one VM listed in the VMs_Always_On.ps1 file
19. Right click the VMs Always On task > Run
20. Check that the VM is starting as expected

## Scheduled Task: Quick Method

1. Download the Scheduled Task export VMs Always On.xml Download
2. Click on the Start Button > Type task > Launch Task Scheduler
3. Right click the Task Scheduler Library folder in the left pane > Import Task...
4. Browse to the downloaded VMs Always On.xml file and select it > Click Open
5. Click the Actions tab > Edit... button
6. In the Add arguments field, update the path to the VMs_Always_On.ps1 file downloaded earlier (Defaults to c:\scripts\)
7. Click OK and OK again to create the scheduled task
8. To test, stop at least one VM listed in the VMs_Always_On.ps1 file
9. Right click the VMs Always On task > Run
10. Check that the VM is starting as expected