Created
December 10, 2012 02:26
-
-
Save beckus/4248027 to your computer and use it in GitHub Desktop.
Starts a VirtualBox Virtual Machine with the maximum possible number of virtual monitors.
This file contains 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
# Starts the specified VirtualBox virtual machine with the maximum number | |
# of virtual monitors (i.e. with the number of virtual monitors matching the | |
# number of physical monitors attached to the PC). | |
# Set these variables as appropriate for your environment. | |
$virtualboxBinFolder = "C:\Program Files\Oracle\VirtualBox" | |
$VMName = "MyVirtualMachine" | |
# Returns the physical monitor count for this PC. | |
Function GetMonitorCount | |
{ | |
# See http://stackoverflow.com/questions/7967699/get-screen-resolution-using-wmi-powershell-in-windows-7 | |
Add-Type -AssemblyName System.Windows.Forms | |
$allScreens = [System.Windows.Forms.Screen]::AllScreens | |
return $allScreens.Length | |
} | |
# Sets the virtual monitor count on the specified VirtualBox virtual machine, | |
# and then starts the machine. | |
# Assumes the $virtualboxBinFolder global variable points to VirtualBox's bin folder. | |
Function StartVMWithMonitorCount ($VMName, $monitorCount) | |
{ | |
& "$virtualboxBinFolder\VBoxManage" modifyvm $VMName --monitorcount $monitorCount | |
& "$virtualboxBinFolder\VBoxManage" startvm $VMName | |
} | |
StartVMWithMonitorCount $VMName (GetMonitorCount) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment