Powershell Script for Always On VirtualBox VMs
#VirtualBox #Powershell #Hypervisor
Full steps can be found at https://i12bretro.github.io/tutorials/0403.html
--------------------------------------------------------------------
Preparation
--------------------------------------------------------------------
01. Download the VMs_Always_On Powershell script https://raw.githubusercontent.com/i12bretro/tutorials/main/_Downloads/VM_Always_On.ps1
02. Open the downloaded VMs_Always_on.ps1 file in a text editor
03. Edit the following:
a. Set the $vboxPath variable to the install path of VirtualBox if it's not installed to the default location
b. Set the $alwaysRunningVMs variable, adding the list of VM names or UUIDs to keep running (These values are case sensitive)
06. Save the changes
07. Copy the file to a location it will run from, c:\scripts for example
--------------------------------------------------------------------
Scheduled Task: Manual Method
--------------------------------------------------------------------
01. Click on the Start Button ≫ Type task ≫ Launch Task Scheduler
02. Right click the Task Scheduler Library folder in the left pane ≫ Create Basic Task...
03. Set the name to VMs Always On and optionally set a Description ≫ Click Next
04. For the Trigger, select When the computer starts ≫ Click Next
05. For the Action, select Start a program ≫ Click Next
06. In the Program/script field, paste the following:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
07. 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"
08. Click Next
09. 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
--------------------------------------------------------------------
01. Download the Scheduled Task export VMs Always On.xml https://raw.githubusercontent.com/i12bretro/tutorials/main/_Downloads/VMs%20Always%20On.xml
02. Click on the Start Button ≫ Type task ≫ Launch Task Scheduler
03. Right click the Task Scheduler Library folder in the left pane ≫ Import Task...
04. Browse to the downloaded VMs Always On.xml file and select it ≫ Click Open
05. Click the Actions tab ≫ Edit... button
06. In the Add arguments field, update the path to the VMs_Always_On.ps1 file downloaded earlier (Defaults to c:\scripts\)
07. Click OK and OK again to create the scheduled task
08. To test, stop at least one VM listed in the VMs_Always_On.ps1 file
09. Right click the VMs Always On task ≫ Run
10. Check that the VM is starting as expected
### Connect with me and others ###
★ Discord: https://discord.com/invite/EzenvmSHW8
★ Reddit: https://reddit.com/r/i12bretro
★ Twitter: https://twitter.com/i12bretro