0403.html 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Powershell Script for Always On VirtualBox VMs</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="How To,Tutorial,i12bretro,Windows,PowerShell,Always On,Script,Virtual Machines">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Powershell Script for Always On VirtualBox VMs">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  12. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  13. <script type="text/javascript" src="includes/js/steps.js"></script>
  14. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  15. </head>
  16. <body>
  17. <div id="gridContainer">
  18. <div class="topMargin"></div>
  19. <div id="listName" class="topMargin">
  20. <h1>Powershell Script for Always On VirtualBox VMs</h1>
  21. </div>
  22. <div></div>
  23. <div id="content">
  24. <h2>Preparation</h2>
  25. <ol>
  26. <li>Download the VMs_Always_On Powershell script <a href="https://raw.githubusercontent.com/i12bretro/tutorials/main/_Downloads/VM_Always_On.ps1" target="_blank">Download</a></li>
  27. <li>Open the downloaded VMs_Always_on.ps1 file in a text editor</li>
  28. <li>Edit the following:
  29. <ol start="1" style="list-style-type: lower-alpha;">
  30. <li>Set the <em>$vboxPath</em> variable to the install path of VirtualBox if it&#39;s not installed to the default location</li>
  31. <li><em>Set the $alwaysRunningVMs&nbsp;</em>variable, adding the list of VM names or UUIDs to keep running (These values are case sensitive)</li>
  32. </ol>
  33. </li>
  34. <li>Save the changes</li>
  35. <li>Copy the file to a location it will run from, c:\scripts for example</li>
  36. </ol>
  37. <h2>Scheduled Task: Manual Method</h2>
  38. <ol>
  39. <li>Click on the Start Button &gt; Type task &gt; Launch Task Scheduler</li>
  40. <li>Right click the Task Scheduler Library folder in the left pane &gt; Create Basic&nbsp;Task...</li>
  41. <li>Set the name to VMs Always On and optionally set a Description &gt; Click Next</li>
  42. <li>For the Trigger, select When the computer starts &gt; Click Next</li>
  43. <li>For the Action, select Start a program&nbsp;&gt; Click Next</li>
  44. <li>In the Program/script field, paste the following:
  45. <p>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</p>
  46. </li>
  47. <li>In the Add arguments field, paste the following, editing the path to the .ps1 file if necessary:
  48. <p>-NoLogo -NoProfile -ExecutionPolicy Bypass -File &quot;C:\Scripts\VMs_Always_On.ps1&quot;</p>
  49. </li>
  50. <li>Click Next</li>
  51. <li>Check the Open the Properties dialog for this task when I click Finish box</li>
  52. <li>Click Finish</li>
  53. <li>In the Properties dialog, select Run whether&nbsp;user is logged on or not</li>
  54. <li>Select the Triggers tab and click the Edit... button</li>
  55. <li>Check the Repeat task every: box and set the value to 5 minutes</li>
  56. <li>Set the for a duration of value to Indefinitely</li>
  57. <li>Click OK to accept the triggers</li>
  58. <li>Click OK again to create the scheduled task</li>
  59. <li>Enter the password for the user the task will run as</li>
  60. <li>To test, stop at least one VM listed in the&nbsp;VMs_Always_On.ps1 file</li>
  61. <li>Right click the&nbsp;VMs Always On task &gt; Run</li>
  62. <li>Check that the VM is starting as expected</li>
  63. </ol>
  64. <h2>Scheduled Task: Quick Method</h2>
  65. <ol>
  66. <li>Download the Scheduled Task export VMs Always On.xml <a href="https://raw.githubusercontent.com/i12bretro/tutorials/main/_Downloads/VMs%20Always%20On.xml" target="_blank">Download</a></li>
  67. <li>Click on the Start Button &gt; Type task &gt; Launch Task Scheduler</li>
  68. <li>Right click the Task Scheduler Library folder in the left pane &gt; Import Task...</li>
  69. <li>Browse to the downloaded&nbsp;VMs Always On.xml file and select it &gt; Click Open</li>
  70. <li>Click the Actions tab &gt; Edit... button</li>
  71. <li>In the Add arguments field, update the path to the VMs_Always_On.ps1 file downloaded earlier (Defaults to c:\scripts\)</li>
  72. <li>Click OK and OK again to create the scheduled task</li>
  73. <li>To test, stop at least one VM listed in the&nbsp;VMs_Always_On.ps1 file</li>
  74. <li>Right click the&nbsp;VMs Always On task &gt; Run</li>
  75. <li>Check that the VM is starting as expected</li>
  76. </ol>
  77. </div>
  78. </div>
  79. </body>
  80. </html>