Last active
August 30, 2017 22:28
-
-
Save mkouhei/f22435f70400162813e809b49ae1260e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$vmname = $one | |
function Show-VM-Info { | |
& "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" showvminfo $vmname | |
} | |
function VM-Powered-off? { | |
Show-VM-Info | Select-String State: | Select-String -quiet 'powered off' | |
} | |
function Start-VM { | |
& "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm $vmname --type gui | |
} | |
function List-VM { | |
& "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" list vms | |
} | |
function VM-Exist? { | |
return (List-VM | Select-String -quiet $vmname) | |
} | |
if (-Not (VM-Exist?)) { | |
echo "[error] '$vmname' is not exists." | |
exit 1 | |
} | |
if (VM-Powered-off?) { | |
Start-VM | |
} else { | |
echo "VM: '$vmname' has been powered on." | |
exit 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment