-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartVMsScript.ps1
More file actions
33 lines (27 loc) · 1.17 KB
/
Copy pathStartVMsScript.ps1
File metadata and controls
33 lines (27 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
$vmboxInstallPath = "C:\Program Files\Oracle\VirtualBox"; # Place here actual path to VirtualBox installation
$vmboxManage = $vmboxInstallPath + "\VBoxManage.exe";
$vmboxHeadless = $vmboxInstallPath + "\VBoxHeadless.exe";
$vmNameRegex = "^""(?<name>.*)"" {(?<uuid>\S{8}-\S{4}-\S{4}-\S{4}-\S{12})}$";
# Start all VMs
Write-Output "Starting VMs..."
$excludeVMs = $null; # Place here VM names or uuid that must be excluded from auto-start. Example: $excludeVMs = "git", "app";
$vms = & $vmboxManage list vms
foreach($vm in $vms) {
$msg = "Controlling " + $vm;
Write-Output $msg
if (-not ($vm -match $vmNameRegex)) {
$msg = "There are error with " + $vm;
Write-Error $msg;
continue;
}
$vmName = $Matches.name
$vmUuid = $Matches.uuid
if ($excludeVMs -contains $vmName -or
$excludeVMs -contains $vmUuid) {
$msg = "VM " + $vm + " excluded from auto-start!";
Write-Output $msg;
continue;
}
$argsList = "-s " + $vmUuid + " -v on"
Start-Process $vmboxHeadless -ArgumentList $argsList
}